Is it possible to define a variable with the type string and then define which possible values that string can have?
colorScheme?: string = 'positive|negative'; //must be a string
and must have the value "positive" or "negative"
Thank you.
UPDATE It does not appear to work when defined in a component:
type ColorScheme = 'positive' | 'negative';
export class MyButtonComponent {
@Input() colorScheme?: ColorScheme;
Now it is correct. Thank you.
colorScheme?: 'positive' | 'negative = ...'colorScheme?: 'positive' | 'negative' = "positive"