Primitive Types and Inference
- Primitive annotations. The primitives are string, number and boolean: written after a colon: let age: number.
- Inference. TypeScript infers most types from the value itself: let name = "Ada" is already a string without an annotation.
- any and unknown. any switches checking off; unknown keeps it on, forcing you to prove a type before using the value.
Variables, Functions and Objects
- Typed functions. A function type names its parameters and its return: function total(items: Item[]): number.
- Object types. An object type lists properties and their types inline: {name: string; age: number} describes a shape.
- const and literal types. const freezes a primitive to a literal type: const mode = "dark" has type "dark", not just string.
Reading TypeScript
- Reading signatures. A signature is documentation that cannot lie: read parameter types and the return type before the body.
- Hover-driven reading. The compiler answers questions live: hovering a symbol reveals its inferred type at that exact spot.
- Error messages. A type error reads inside-out: the last lines name the concrete mismatch, the first name where it surfaced.
Before and after this level
- Before: Start Here: Why TypeScript Exists: JavaScript With a Type System, Compile Time vs Runtime.
- Next: Level 2: Object Types: Interfaces and Type Aliases, Optional and Readonly Properties, Structural Typing.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does TypeScript Level 1: TypeScript Foundations cover?
Primitive Types and Inference, Variables, Functions and Objects, Reading TypeScript: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Start Here: Why TypeScript Exists, which covers JavaScript With a Type System, Compile Time vs Runtime.