Skip to main content
PProfileMatch

TypeScript Tutorial

Learn TypeScript from the ground up: types, unions, generics, narrowing and a sane tsconfig

Beginner to Intermediate4 lessonsabout 21 min of reading

This course is for JavaScript developers who keep hearing that TypeScript will save them from bugs and want to know what that means in practice. If you can write functions, objects and arrays in JavaScript (see JavaScript fundamentals if not), you are ready. You do not need to install anything to follow the ideas, but TypeScript is easiest to learn with an editor such as VS Code open so you can hover over names and see the types it infers.

The lessons use four small domains: a bike-share station, a customer-support event feed, a paginated music library and a member profile update. Together they cover what you will use every day: annotations and inference, interfaces and type aliases, union types that model "one of these shapes", generics for reusable code, narrowing to move from vague types to precise ones, utility types that derive new types from old ones, and the tsconfig options worth turning on.

The order follows how TypeScript is actually learned. First the basic types and how much the compiler works out for itself. Then the modelling tools: interfaces, aliases and unions. Then generics, which make the earlier tools reusable. Finally narrowing, utility types and configuration, which is where code written for the type checker starts to feel natural. Where compiler messages are quoted, they come from TypeScript 5.9; the wording can differ slightly between versions, but the meaning does not.

TypeScript lessons

  1. 1TypeScript Types and Type Inference: A Practical IntroductionLearn TypeScript basic types, annotations and type inference: strict mode, null checks, arrays, tuples, function signatures and why unknown beats any.5 min read
  2. 2TypeScript Interfaces, Type Aliases and Union TypesModel data in TypeScript with interfaces, type aliases, union and intersection types, and discriminated unions with exhaustive switch checks.5 min read
  3. 3TypeScript Generics Explained: Functions, Interfaces and ConstraintsLearn TypeScript generics with practical examples: generic functions, interfaces, classes, constraints with extends and keyof, and default type parameters.5 min read
  4. 4TypeScript Narrowing, Utility Types and tsconfig.json SetupMaster TypeScript type narrowing and type guards, utility types like Partial, Pick, Omit and Record, and a practical tsconfig.json for Node and web projects.6 min read

Preparing for an interview? Practise JavaScript interview questions

Learning TypeScript to land a job? Browse open roles or check which skills are trending.