0Pricing
TypeScript Academy · Lesson

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

  1. Primitive Types & Annotations
  2. Type Inference & any vs unknown
  3. Union & Literal Types (basic narrowing intro)
← Back to TypeScript Academy