Skip to content

Glossary: TypeScript Basics

as (type assertion)

Also written: as, type assertion, type assertions

Writing `value as Type` tells TypeScript to treat the value as that type, with no check at run time. If you're wrong, as with `JSON.parse(text) as OrderItem` on JSON that says `quantity`, the bug slips through.

Where the book teaches it

Related terms

non-null assertionunknownnarrowing