TypeScript Types

string — primitive text type

Use string for JavaScript primitive text values. It accepts text of any length, including the empty string; it does not enforce a format such as an email address. String (capital S) describes a wrapper-compatible interface, not the preferred primitive annotation. Methods such as toUpperCase return new text rather than changing the original value. Example output: "READY". The example was designed for strict checking with an ES2022 target; type annotations do not add runtime validation.

Formal Syntax & Structure

typescript syntaxtypescript
let value: string;

Working Example

Example Snippettypescript
const label: string = "ready";console.log(label.toUpperCase());
TypeScript Reference