To convert the first letter of string literal type into a lowercase format or uncapitalize, you can use the built-in Uncapitalize type that comes with TypeScript.
TL;DR
// string literal type
type Greeting = "HELLO WORLD";
// convert first letter of
// string literal type
// into lowercase format or uncapitalize
type GreetingUncapitalized = Uncapitalize<Greeting>; // hELLO WORLD
For example, let's say we have a string literal type like this,
// string literal type
type Greeting = "HELLO WORLD";
Now to uncapitalize the string literal type let's use the Uncapitalize built-in type and pass the Greeting type into it using the angled bracket (<>) syntax.
It can be done like this,
// string literal type
type Greeting = "HELLO WORLD";
// convert first letter of
// string literal type
// into lowercase format or uncapitalize
type GreetingUncapitalized = Uncapitalize<Greeting>; // hELLO WORLD
Now if you hover over the GreetingUncapitalized type you can see that the HELLO WORLD string literal type is now uncapitalized. Yay 🥳.
See the above code live in codesandbox.
That's all 😃!
              
    
Top comments (0)