Learn TypeScript
Add a type system to your JavaScript. Learn type inference and annotations, typed functions, arrays and tuples, enums, object types, generics, unions, type narrowing and interfaces, and let the compiler catch bugs before your code runs.
- Intermediate level
- 7 modules
- 48 lessons
- 173 tasks and questions
Syllabus
01TypesMeet TypeScript: what it adds to JavaScript, how the compiler checks your code before it runs, type inference, type shapes, the any type, type annotations and the strict compiler settings this course uses.7 lessons
02FunctionsType your functions: annotate parameters, make them optional or give them defaults, let TypeScript infer return types or declare them yourself, use void for functions that return nothing, and document functions with JSDoc comments.7 lessons
03Arrays and TuplesGive arrays element types, nest them for grids, fix their length and order with tuples, see where array inference needs your help, and type rest parameters and spread arguments.6 lessons
04Custom TypesCreate your own types: enums for fixed sets of options, object types for structured data, type aliases to name and reuse types, function types for callbacks, and generic types and functions that work with many element types.8 lessons
05Union TypesCombine types with unions: accept values of several types, narrow them with typeof, read union return types, type mixed arrays, use the members all union types share, and restrict values to exact options with literal types.7 lessons
06Type NarrowingUse the checks you already write in JavaScript, typeof, equality, the in operator, if...else and early returns, as type guards that tell TypeScript exactly which member of a union you're working with.5 lessons
07Advanced Object TypesDescribe objects with interfaces: compare them with type aliases, check classes with implements, nest and compose object types, extend interfaces, allow unknown keys with index signatures, and mark properties as optional.8 lessons