Reputation: 19
So I have an enum like this:
enum StringsVals {
'aaa',
'bbb',
'ccc'
}
and I define a variable x which can be an array of enum values like so:
const x: (keyof typeof StringsVals)[] = ['aaa', 'bbb']
Is there a way I can make sure that x only contains those values and they are unique in order to avoid this for example?
const x: (keyof typeof StringsVals)[] = ['aaa', 'bbb', 'aaa', 'aaa']
Or there is so much that Typescript can do?
enum StringsVals {
'aaa',
'bbb',
'ccc'
}
const x: (keyof typeof StringsVals)[] = ['aaa', 'bbb']
Upvotes: 1
Views: 56