Reputation: 818
Lets assume I have an access to a type Keys
that is defined like so:
type Keys = ('AA' | 'BB' | 'CC')[]
Key
, using type Keys
, so that this new type be equal to:type Key = 'AA' | 'BB' | 'CC'
Note that I cannot literally specify allowed values (AA
, BB
, etc), I only have Keys
type available to work with.
Upvotes: 0
Views: 243
Reputation: 249486
You can use an indexed type query:
type Keys = ('AA' | 'BB' | 'CC')[]
type Key = Keys[number]
Upvotes: 1