I have a string literal union type that looks like this:
type LowerCaseNames = 'youku-frame' | 'youku' | 'mini-program' | 'tiktok-frame';
This is only an example, since my union type is a list of more than 100 cases.
What I need to have is a new type where I would have the following "values" in type:
type UpperCaseNames = 'YOUKU_FRAME' | 'YOUKU' | 'MINI_PROGRAM' | 'TIKTOK_FRAME';
So far, I am using TypeScript's Uppercase type in order to have it upper-cased.
type UpperCaseNames = `${Uppercase<LowerCaseNames>}`;
What this returns is upper-cased union type but, I still have in them - instead of _.
Is there a way for me to create a type that I can use like this ${Replace<Uppercase<LowerCaseNames>>} in order to replace - with _?
I am using Typescript v4.4.4.
-to_buuut apparently that's a limitation of theUppercase<T>type"-".toUpperCase()is just"-"so I'm not sure why you think it would be"_". (Capitalization is not the same as pushing a shift key on a keyboard)