Types basics

This part is the type notes themselves: strings, numbers and booleans first, then any, unknown and never, arrays and tuples, type aliases and interfaces, and the unions and literal values that replace a plain string. Every example is checked by the compiler before it runs.

2.1 Basic types annotate strings, numbers and booleans, and let TypeScript infer what it already knows Open 2.2 any, unknown, never any opts out of checking, unknown forces a check first, never marks code that cannot return Open 2.3 Arrays and tuples string[] and Array syntax, tuples for fixed pairs, and readonly arrays Open 2.4 Type aliases name reusable types with type, compose them into objects, and compare them with interfaces Open 2.5 Interfaces object shapes with interfaces, optional and readonly members, and one interface extending another Open 2.6 Unions and literals unions, narrowing with typeof, literal values, and when a union beats an enum Open

Lessons