Open In App

TypeScript Uncapitalize<StringType> Template Literal Type

Last Updated : 25 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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 which 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-

  • Uncapitalize is the utility type used to lowercase the first character of the string.
  • StringType is the string type you want to uncapitalize.

Example 1: In this example, we will see 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.

 

Javascript




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


Output:z74

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.

Javascript




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


Output:z75


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads