TypeScript
Add type safety to your JavaScript projects. Learn TypeScript fundamentals and how to build scalable applications with confidence.
Learn TypeScript step by step — types, interfaces, generics, classes and React with TypeScript — through practical interactive lessons.
Part of the free TypeScript course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
Know JavaScript? TypeScript is your next step.
Start with Lesson 1 — Introduction to TypeScript. We recommend finishing the JavaScript course first, but it's not required.
Lessons in this course
- Introduction to TypeScript — What TypeScript adds to JavaScript and how to set up your first TS project
- Basic Types — string, number, boolean, arrays, tuples, and the any/unknown types
- Interfaces and Type Aliases — Define the shape of objects and create reusable custom types
- Functions and Generics — Type your function parameters and return values; write flexible generic functions
- Classes and Objects — Access modifiers, readonly, abstract classes, and OOP in TypeScript
- Advanced Types — Union, intersection, conditional types, mapped types, and utility types
- Union & Intersection Types — Combine types with A | B and A & B, and narrow them safely
- Literal Types & const Assertions — Exact string/number types and locking values with as const
- Enums — Numeric and string enums, const enums, and enum vs union-of-literals
- Type Narrowing & Type Guards — Narrow types with typeof, instanceof, in, and custom type guards
- Generics — Write reusable, type-safe functions, interfaces and classes
- Object Types: Optional, Readonly & Index Signatures — Model flexible objects with ?, readonly, and index signatures
- Function Overloads & this Types — Overload signatures, call signatures, and typing this
- Arrays, Tuples & Readonly Arrays — Typed arrays, fixed-shape tuples, named members, and readonly
- Checkpoint: The Type System — Combine unions, generics and tuples in a build — then a quiz
- Utility Types (Partial, Pick, Omit, Record) — Transform types with the built-in utility types
- Mapped Types — Build new types by transforming the keys of existing ones
- Conditional Types & infer — T extends U ? X : Y, distribution, and extracting types with infer
- Generic Constraints & Defaults — Restrict type parameters with extends and provide defaults
- keyof, typeof & Lookup Types — Type-safe property access with keyof, the typeof operator, and T[K]
- Discriminated Unions — Model states and results with a discriminant and exhaustive checks
- Modules & Declaration Files — import/export, type-only imports, and ambient .d.ts declarations
- tsconfig & Compiler Options — strict mode, target/module, and the options that matter most
- Checkpoint: Advanced Types — Combine mapped types, discriminated unions and generics — then a quiz
- Type Assertions & Non-null (as, !) — Tell the compiler a type with as and !, and when it's safe vs dangerous
- any vs unknown vs never — The three special types — escape hatch, safe unknown, and impossible never
- void, null & undefined — Model absence and no-return correctly under strictNullChecks
- Structural Typing (Duck Typing) — Why TypeScript matches types by shape, not by name
- type vs interface — When to use each — merging, extends, unions, and style guidance
- readonly, as const & Immutability — Lock values at compile time with readonly, ReadonlyArray, and as const
- Records & Index Signatures — Type dictionaries with index signatures and Record<K, V>
- Template Literal Types — Build string types from other types — event names, key prefixes, and more
- Recursive Types — Model JSON, trees, and deep-readonly with self-referential types
- The satisfies Operator — Check a value against a type without widening its literal inference
- Branded (Nominal) Types — Stop mixing ids and units by giving primitives a unique brand
- Checkpoint: Type-Level Patterns — Combine satisfies, branded and template-literal types — then a quiz
- Declaration Merging — Merge interfaces and augment modules and the global scope
- Namespaces — Group code with namespaces, and why ES modules are usually better
- Ambient Declarations & @types — Type untyped JavaScript with declare, .d.ts files, and DefinitelyTyped
- Typing Promises & async/await — Promise<T>, Awaited<T>, and typing a fetch wrapper
- DOM & Event Types — Type elements, queries, and events without casting everywhere
- Generic Defaults & Inference — Default type parameters, how inference works, and when to annotate
- Function Types, this, Parameters & ReturnType — Type functions precisely and extract their parameter and return types
- Variadic Tuple Types — Spread and label tuple elements to type curry, concat, and rest args
- Advanced Utility Types — Awaited, Parameters, ReturnType, NonNullable — and build your own with infer
- Decorators — Stage-3 class, method, and field decorators and how they work
- Migrating JavaScript to TypeScript — Adopt TS incrementally with allowJs, JSDoc, @ts-check, and gradual strict
- Checkpoint: Applied TypeScript — Build a small typed module combining several features — then a quiz
- TypeScript with React — Type your React components, props, hooks, and events correctly
- TypeScript Best Practices — Real-world patterns, strictness settings, and tips for clean TS codebases
- Runtime Validation with Zod — Validate data at runtime and infer static types from a single Zod schema
- Testing TypeScript — Write type-safe tests with Vitest/Jest, typed mocks, and async assertions
- TypeScript on Node.js — Configure tsconfig for Node, @types/node, ESM vs CommonJS, and ts-node/tsx
- Building APIs with Express and TypeScript — Type requests, responses, and middleware for a clean Express REST API
- Authoring and Publishing TypeScript Libraries — Emit .d.ts declarations, configure package.json exports, and publish to npm