Type Inference & any vs unknown
See how TypeScript infers types, the difference between any and unknown, and how const changes inference.
Intro
Goal: Learn how TS infers types from values, and compare any vs unknown for safety.
Inference with let & const
Inference: let infers a broad type (number). const infers a literal type ("TS").
let count = 5;
// inferred number
const title = "TS";
// inferred literal type "TS"
console.log(count, title);All lessons in this course
- Primitive Types & Annotations
- Type Inference & any vs unknown
- Union & Literal Types (basic narrowing intro)