On this page
Capitalize
Prev: `Lowercase` | Up: string_manipulation | Next: `Uncapitalize`
Rel: string_manipulation, Conditional & Mapped Types
Ref: TypeScript Docs — Utility Types
Tags: #public #web #typescript #utility-types #string_manipulation #tier/standard
Syntax & Overview
Capitalize<S>
Uppercases the first character of string literal type S.
Notes & Pitfalls
- Intrinsic template-literal helper: Uppercases only the first character—great for generating
onClick/setNameaccessor names.
Example
type EventName<K extends string> = `on${Capitalize<K>}`;
type ClickEvent = EventName<"click">; // "onClick"
Linked from
Related notes
- tuts/typescript/utility_types/string_manipulation/Lowercase Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/string_manipulation/Uncapitalize Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/string_manipulation Linked here; links to this page; shared tags: #typescript, #web
- tuts/typescript/type_system/conditional_and_mapped_types Linked here; shared tags: #typescript, #web
- tuts/typescript/builtins/any shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/as_const shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/enum shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/infer shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #tier, #typescript, #web