Open In App

TypeScript Uncapitalize<StringType> Utility Type

In this article, we are going to learn about Uncapitalize<StringType> Template Literal Type in Typescript. Typescript is a popular programming language used for building scalable and robust applications. One of the features of Typescript is Uncapitalize<StringType> Template Literal Type is a built-in utility type that helps with string manipulation. It helps to convert the first character in the string to a lowercase equivalent.

Syntax:

type UncapitalizedString = Uncapitalize<StringType>;

Where-



Example 1: This example shows a simple example of using Uncapitalize<StringType> Template Literal. We will take a string with the first character capital and then use Uncapitalize which will help to initialize a constant with a string with the first character in lowercase.

 






type gfg = "Geeksforgeeks";
type geek = Uncapitalize<gfg>;
const result: geek = "geeksforgeeks";
console.log(result);

Output:

Example 2: In this example, we will see how to manipulate string union. We will take multiple strings using ‘or’ with the first character capital and then use Uncapitalize which will help to initialize a constant with a string with the first character in lowercase.




type symbols = "Alpha" | "Beta" | "Gema";
type geek = Uncapitalize<symbols>
const result: geek = "alpha"
console.log(result)

Output:

Article Tags :