LEVEL 5 · TYPESCRIPT
Course Foundation
TypeScript
Add a type system to JavaScript: what TypeScript is and is not, everyday types and inference, unions and narrowing, interfaces, generics, classes, modules, tsconfig, and where types stop and runtime validation begins.
0 of 21 lessons done
When you finish, you can
- Explain type erasure and why types never validate outside data
- Type functions, objects, arrays and tuples, and know when to let inference work
- Model domain states with literal and discriminated unions
- Narrow unknown values safely with guards and assertion functions
- Write generic functions, interfaces and classes
- Configure a project with tsconfig.json and strict mode
- Validate external data at runtime and return typed errors
You build: A typed task manager and a typed CLI calculator
MODULE 1
Why TypeScript
- 1Why TypeScript existsSee a bug that JavaScript runs without complaint, install TypeScript, write a tsconfig.json, and learn the three ways to run TypeScript on Node.js 24.35 min
- 2What the TypeScript compiler doesFollow a TypeScript file through tsc: checking, type erasure, transpiling to older JavaScript, emitted files, watch mode and Node's type stripping.45 min
MODULE 2
Everyday types
- 3Basic typesThe everyday types of TypeScript - strings, numbers, booleans, arrays, tuples and object types - plus any vs unknown, null and undefined under strict mode, void, and never for exhaustive checks.35 min
- 4Type inference in depthSee how TypeScript works out the types you never wrote (literals, widening, contextual typing, inferred returns) and decide where an annotation pays off.40 min
- 5Typing functionsGive functions parameter and return types, use optional, default and rest parameters, describe functions and callbacks as types, type async functions with Promise, and meet overloads.35 min
- 6Interfaces, unions and literal typesName object shapes with interfaces and type aliases, mark properties optional or readonly, extend and combine shapes, and model data that can take several forms with unions, literal types and discriminated unions.40 min
- 7Union types in depthModel real states with discriminated unions, return typed results instead of throwing, combine shapes with intersections, and avoid common union mistakes.50 min
- 8Type aliases and interfacesName your domain types once, extend them safely, use declaration merging and recursive types, and learn the real differences between type and interface.45 min
MODULE 3
Special types and narrowing
- 9Special types: any, unknown, never and friendsLearn what any, unknown, never, void, object, {} and Object really mean, watch one any spread, and use unknown at your program's boundaries.45 min
- 10NarrowingTurn wide union and unknown types into precise ones with typeof, truthiness, equality, in, instanceof, discriminants, type guards and assertion functions, and learn where narrowing lies.50 min
- 11Type assertionsLearn what as, angle-bracket assertions, as unknown as and the non-null ! really do, see why none of them check or convert anything, and replace them with safer tools.40 min
- 12Enums and their alternativesWrite numeric, string and const enums, read the exact JavaScript tsc emits for each, learn the pitfalls and erasableSyntaxOnly, and replace enums with unions and as const objects.45 min
- 13TuplesType fixed-shape arrays with tuples - optional, rest and named elements, readonly tuples, tuple inference and const type parameters - and return tuples from functions the way useState does.40 min
MODULE 4
Generics and type operators
- 14GenericsWrite one function, interface or class that works for many types without losing type safety, set rules with constraints and keyof, give type parameters defaults, and build a Result type and a generic repository.35 min
- 15Designing generic APIsDesign generic interfaces and classes that stay easy to call - type parameters that earn their place, inference, NoInfer, keyof constraints and defaults - by building Repository, Result, Page, ApiResponse, Cache and typed events.55 min
- 16Advanced and utility typesBuild new types from existing ones with keyof, typeof, indexed access, mapped, conditional and template literal types, and use the built-in utility types (Partial, Pick, Omit, Record, ReturnType, Awaited and more) to keep one source of truth.45 min
MODULE 5
Classes, modules and configuration
- 17Classes in TypeScriptDeclare typed class properties, use parameter properties and access modifiers, compare private with #private, write abstract classes and classes that implement interfaces, and wire classes together with constructor injection.40 min
- 18Modules in TypeScriptSplit a TypeScript project into files, import types with import type, see why verbatimModuleSyntax exists, write .js in import paths, and understand how NodeNext resolution, "type" - "module" and the "exports" field fit together.40 min
MODULE 6
Types meet the runtime
- 19TypeScript and JavaScript togetherSee exactly what TypeScript becomes when it runs, why types cannot check outside data, and how to close that gap by hand with type guards, assertion functions and a validator that returns a Result.45 min
- 20Typed error handlingCatch errors as unknown, write error classes with a name, a cause and a literal code, return typed results, and handle async failures in a payments service.55 min
- 21Async TypeScriptType promises and async functions precisely, keep Promise.all tuples intact, narrow allSettled results, use Awaited, and page through an API with typed async generators.55 min
Course checkpoint
Prove you can move on. The checkpoint picks 20 questions at random from every lesson in this course. Get 16 right to pass. Your result is saved in this browser only.