Uncapitalize<T> for First Character Lowering
What you'll learn: How to use TypeScript's Uncapitalize<T> utility type to transform only the first character of a string literal type to lowercase.
What Is Uncapitalize<T>?
Uncapitalize<T> is the inverse of Capitalize<T>. While Capitalize<T> makes the first character uppercase, Uncapitalize<T> converts only the first character of a string literal type to lowercase, leaving the rest of the string unchanged.
Think of it like converting a proper noun back to a common noun: "JavaScript" becomes "javaScript", "TypeScript" becomes "typeScript". Only that first letter changes.
Basic Syntax and Usage
type LowercasedFirst = Uncapitalize<"Hello">;
// Result: "hello"
type NoChange = Uncapitalize<"world">;
// Result: "world" (already lowercase)
type PartialLower = Uncapitalize<"TypeScript">;
// Result: "typeScript"
When It Matters
Uncapitalize<T> is particularly useful when converting between naming conventions or normalizing string literal types:
type PascalCase = "UserProfile" | "AdminPanel" | "SettingsPage";
type CamelCase = Uncapitalize<PascalCase>;
// Result: "userProfile" | "adminPanel" | "settingsPage"
Real-World Pattern: Property Name Conversion
This pairs well with template literal types for transforming object keys:
type EventName = "Click" | "Focus" | "Blur";
type HandlerName = `on${EventName}`;
// "onClick" | "onFocus" | "onBlur"
type DataKey = Uncapitalize<EventName>;
// "click" | "focus" | "blur"
Key Takeaway: Uncapitalize<T> transforms only the first character of a string literal type to lowercase, making it perfect for normalizing naming conventions or converting between PascalCase and camelCase at the type level.