Capitalize<S>

Converts the first character of the string literal type S to uppercase.

Since TS 4.1 Spec ↗

Syntax

Capitalize<StringType>

Returns

string literal type — A string literal type with the first character uppercased.

Examples

type Title = Capitalize<'hello'>; // 'Hello'
type Getter<T extends string> = `get${Capitalize<T>}`;
type GetName = Getter<'name'>; // 'getName'

Notes

An intrinsic compiler type. Only the first character is affected; the rest of the string is unchanged. Distributes over unions. Use `Uncapitalize` for the inverse.

See also