string-manipulation
Uncapitalize<S>
Intrinsic type utility that lowercases the first character of literal S, leaving the rest unchanged. The inverse of Capitalize and widely used for PascalCase-to-camelCase mappings.
type Uncapitalize<S extends string> = intrinsic Usage patterns
| Pattern | Purpose |
|---|---|
| Uncapitalize<'Foo'> | Basic first-letter lowercase |
| `on${Capitalize<E>}` | Event handler naming pattern (paired inverse of Uncapitalize) |
| Uncapitalize<K & string> | Narrow keyof T to string before transform |
| Uncapitalize<Capitalize<S>> | Normalize to a guaranteed leading-lowercase form |
Examples
type U = Uncapitalize<'Foo'>; Result: 'foo'
type CamelKeys<T> = { [K in keyof T as Uncapitalize<K & string>]: T[K] }; Rewrites PascalCase keys to camelCase
type Events = 'Click' | 'Focus';
type E = Uncapitalize<Events>; Result: 'click' | 'focus'
type S = Uncapitalize<string>; Result: string when input is not a literal
Gotcha
Only mutates the first character — subsequent characters remain untouched, so ALLCAPS becomes aLLCAPS not allcaps. Non-literal inputs widen to `string`.
Related utility types
Capitalize<S>
Intrinsic string type utility that uppercases the first character of literal string S, leaving the rest unchanged. Enables typed camelCase-to-PascalCase and getter-name construction.
Uppercase<S>
Compile-time intrinsic that converts a string literal type S to its uppercase form. Introduced in TS 4.1 alongside template literal types.
Lowercase<S>
Intrinsic string type manipulator that converts each character of literal S to lowercase. Available since TS 4.1 and evaluated by the compiler with no runtime cost.
Record<K, V>
Creates an object type whose keys come from the union K and whose values all have type V. Useful for lookup tables, dictionaries, and enum-keyed maps.
← All TS utility types · TypeScript vs JavaScript · any vs unknown vs never