I have enum that looks like this
export enum Alignment {
Top = 'top',
Right = 'right',
Bottom = 'bottom',
Left = 'left',
}
Commonly I will use it in defining interface for e.g. react component props like
interface CompProps {
align: Alignment;
}
But now wonder if I can use only the part of this enum, like
interface CompProps {
align: `part of Alignment: left and top`;
}
Is there a common pattern for this?
I may think of:
A. align: Alignment.Left | Alignment.Top;
B. creating new enum for this task like
enum CompAlignment {
Top = Alignment.Top,
Left = Alignment.Left,
}
align: Alignment.Left | Alignment.Top;should work best.