string-manipulation

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.

type Uppercase<S extends string> = intrinsic

Usage patterns

Pattern Purpose
Uppercase<'hello'> Basic uppercase of a literal
Uppercase<`get_${string}`> Combine with template literal types
Uppercase<T> & string Ensure result stays assignable to string
as Uppercase<'x'> Assertion to lock a value's literal case

Examples

type H = Uppercase<'hello'>;

Result: 'HELLO'

type Env = 'dev' | 'prod';
type LoudEnv = Uppercase<Env>;

Distributes over unions: 'DEV' | 'PROD'

type Header<K extends string> = `X-${Uppercase<K>}`;
type H = Header<'id'>; // 'X-ID'

Composing with template literal types

type S = Uppercase<string>;

Result: string (widens when the input is not a literal)

Gotcha

Only affects string LITERAL types — passing a plain `string` widens the result back to `string`. Purely a compile-time transformation, so no runtime toUpperCase call is generated.

Related utility types

← All TS utility types · TypeScript vs JavaScript · any vs unknown vs never