TypeScript Syntax and Type Operators

as — type assertion

A type assertion requests a different static view of an expression when the compiler permits the relationship. It is erased, so it neither converts values nor checks their runtime shape. Direct assertions between sufficiently unrelated types are rejected, but an intermediate unknown assertion can bypass that safeguard. Use a guard or validation when the value is not trusted. Example output: "5". Tested in the strict TypeScript 5.8.3 / ES2022 baseline; the example is not a runtime type validator.

Formal Syntax & Structure

typescript syntaxtypescript
const title = value as string;

Working Example

Example Snippettypescript
const value: unknown = "ready";const title = value as string;console.log(title.length);
TypeScript Reference