Skip to content

toUpperCase ​

The toUpperCase() method returns a new string with all characters in uppercase.

Interactive example ​

Syntax ​

typescript
function toUpperCase<
	GenericInput extends string
>(
	input: GenericInput
): Uppercase<GenericInput>;

Parameters ​

  • input: The string to modify. The type is generic (GenericInput extends string) to allow precise literal type inference.

Return value ​

A new string with all characters in uppercase. The return type is precisely inferred thanks to TypeScript's Uppercase<GenericInput> utility type.

See also ​

  • toLowerCase: Converts the entire string to lowercase.
  • capitalize: Uppercases the first letter of a string.
  • normalize: Normalizes a Unicode string according to a specific form.

Sources ​

Released under the MIT license.