TypeScript Concepts

Type erasure — static types disappear

Type annotations, aliases, interfaces and type arguments normally vanish from emitted JavaScript. Runtime values and their ordinary JavaScript operations remain. A type assertion does not validate data. Some TypeScript syntax, such as ordinary enums, requires runtime code generation; type erasure is not equivalent to removing every TypeScript-specific construct. Observed output: 'string A1'. Local example verified with TypeScript 5.8.3, strict checking, ES2022/CommonJS and Node.js 22.16.0; declarations enabled.

Formal Syntax & Structure

typescript syntaxtypescript
type Id = string; const id: Id = "A1";

Working Example

Example Snippettypescript
type TicketCode = string;const code: TicketCode = "A1";console.log(typeof code, code);
TypeScript Reference