Uppercase<S>
Converts each character in a string literal type to its uppercase equivalent using intrinsic compiler support.
Definition
type Uppercase<S extends string> = intrinsic;Examples
type Loud = Uppercase<"hello world">;
// "HELLO WORLD"
type Status = "active" | "inactive" | "pending";
type UpperStatus = Uppercase<Status>;
// "ACTIVE" | "INACTIVE" | "PENDING"type EventName = "click" | "scroll" | "resize";
type ConstantName = `ON_${Uppercase<EventName>}`;
// "ON_CLICK" | "ON_SCROLL" | "ON_RESIZE"
type EventConstants = Record<ConstantName, string>;
const events: EventConstants = {
ON_CLICK: "click",
ON_SCROLL: "scroll",
ON_RESIZE: "resize",
};type HttpHeader = "content-type" | "authorization" | "cache-control";
type NormalizedHeader = Uppercase<HttpHeader>;
// "CONTENT-TYPE" | "AUTHORIZATION" | "CACHE-CONTROL"
function normalizeHeader<T extends string>(header: T): Uppercase<T> {
return header.toUpperCase() as Uppercase<T>;
}Common Use Cases
- 1Generating constant names from lowercase identifiers
- 2Normalizing string types to uppercase
- 3Building template literal types with uppercase segments
- 4Creating enum-like type mappings
- 5HTTP header and environment variable name patterns
Understanding Uppercase<S>
Uppercase<S> is an intrinsic string manipulation type that converts every character in a string literal type to uppercase. Unlike most TypeScript utility types which are defined in terms of other types, Uppercase is implemented directly in the compiler using the intrinsic keyword.
The intrinsic implementation means Uppercase performs actual character transformation at the type level. Given "hello", it produces "HELLO"—not through conditional types or mapped types, but through built-in compiler logic that applies the same transformation as String.prototype.toUpperCase.
Uppercase is commonly combined with template literal types to generate derived string types. For example, if you have event names like "click" and "scroll", you can generate constant names: `ON_${Uppercase<EventName>}` produces "ON_CLICK" | "ON_SCROLL". This pattern is excellent for maintaining type-safe mappings between different naming conventions.
The type distributes over unions automatically. If S is "a" | "b" | "c", Uppercase<S> is "A" | "B" | "C". This distribution makes it straightforward to transform entire sets of string literals in one expression.
Uppercase is part of a family of four intrinsic string types: Uppercase, Lowercase, Capitalize, and Uncapitalize. Together they cover the most common string case transformations needed in type-level programming. These types bridge the gap between runtime string operations and compile-time type safety.
A practical tip: when implementing a runtime function that matches Uppercase behavior, return the result with a type assertion: return str.toUpperCase() as Uppercase<T>. This ensures the return type stays in sync with the type-level transformation.
Related Types
Lowercase<S>Converts each character in a string literal type to its lowercase equivalent using intrinsic compiler support.
Capitalize<S>Converts the first character of a string literal type to uppercase while leaving the rest unchanged.
Uncapitalize<S>Converts the first character of a string literal type to lowercase while leaving the rest unchanged.
Template Literal TypesTemplate literal types combine string literal types with embedded expressions to create powerful string pattern types.
More String Types
Explore TypeScript Types
Browse our complete reference of 30 TypeScript utility types with definitions, examples, and explanations.