TypeScript
Safe, scalable JavaScript with types
Learn TypeScript on top of the JavaScript you already know: types and type inference, typed functions and objects, unions and narrowing, classes, generics and utility types. You will see how the compiler catches bugs before the code runs and makes your editor smarter. By the end of the course you will set up TypeScript projects yourself and write safe, well-typed code with modern patterns such as `satisfies`, `as const` and declaration files.
Course content
TypeScript foundations
BeginnerSet up TypeScript, learn the basic types and type inference, and add types to your functions.
- 1Why TypeScript?Find out what TypeScript adds to JavaScript, how the compiler catches bugs before the code runs, and how to set up a project with `tsc`, `tsconfig.json` and Node.js.14 min
- 2Basic types and inferenceMeet `string`, `number`, `boolean`, arrays and tuples, see how TypeScript works out types by itself, and learn the difference between `any` and `unknown` and what literal types are.15 min
- 3Typed functionsAdd types to function parameters and return values, use optional, default and rest parameters, and describe function types.15 min
Modeling data with types
IntermediateDescribe objects with interfaces and type aliases, combine and narrow types, and write typed classes.
- 4Interfaces and type aliasesDescribe the shape of objects with `interface` and `type`, use optional and `readonly` properties, extend interfaces and learn when to choose which.16 min
- 5Unions and narrowingCombine types with `|` and `&`, narrow them with `typeof`, `in` and comparisons, build discriminated unions and write your own type guards.18 min
- 6Classes and enumsAdd typed fields to classes, control access with `public`, `private`, `protected` and `readonly`, check a class against an interface with `implements`, and compare `enum` with unions of literal types.17 min
Advanced TypeScript
AdvancedWrite reusable code with generics and utility types, and master strict mode, `satisfies`, `as const` and declaration files.
- 7Generics and utility typesWrite functions and interfaces that work with any type without losing type information, constrain them with `extends` and `keyof`, and build new types with `Partial`, `Pick`, `Omit`, `Record` and `ReturnType`.18 min
- 8Modern patterns and declaration filesLearn what strict mode catches, get precise types with `as const` and `satisfies`, and type third-party JavaScript libraries with `.d.ts` declaration files.20 min