type a = 'one' | 'two'
I would like to have a type b
like
type b = 'ONE' | 'TWO'
So I tried
type a = 'one' | 'two'
type b = {[P in a]: P['toUpperCase']}
But that does not do what I want it to do.
Thank you for reading :)
You can now do this in the coming 4.1 release, with the introduction of Template Literal Types:
type A = 'one' | 'two'
type B = `${Uppercase<A>}`
let b: B = 'one' // Type '"one"' is not assignable to type '"ONE" | "TWO"'.
TS Playground
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With