Intrinsic String Manipulation Types
Use Uppercase, Lowercase, Capitalize, and Uncapitalize.
Built-In String Transformers
TypeScript ships four intrinsic string manipulation types: Uppercase, Lowercase, Capitalize, and Uncapitalize. They transform string literal types at compile time, with no runtime cost.
Uppercase
Uppercase<S> converts every character of a string literal type to upper case. The literal 'hello' becomes the type 'HELLO'.
type Loud = Uppercase<"hello"> // "HELLO"
const x: Loud = "HELLO"
console.log(x)All lessons in this course
- Template Literal Type Basics
- Modeling Structured Strings
- String Unions and Autocomplete
- Intrinsic String Manipulation Types