Free tutorial · 25 lessons
TypeScript Tutorial
Learn TypeScript step by step: types, interfaces, unions, narrowing, functions, classes, enums, generics, utility types, mapped and conditional types, discriminated unions and async code — with examples you can run in your browser.
TypeScript Basics
- TypeScript Introduction — What TypeScript adds to JavaScript and why most large projects use it.
- TypeScript Get Started — Install TypeScript, compile with tsc and configure tsconfig.json.
- TypeScript Basic Types — Annotate variables with string, number, boolean, arrays and more — and let inference do the rest.
- TypeScript Object Types and Type Aliases — Describe object shapes, optional and readonly properties, and name types with type.
- TypeScript Index Signatures and Records — Type objects used as dictionaries with index signatures and Record.
- TypeScript Readonly and Immutability — readonly properties, ReadonlyArray, as const and Readonly<T>.
- TypeScript Interfaces — Describe object shapes with interface, extend them and compare with type aliases.
- TypeScript Union and Literal Types — Allow several types with |, restrict values with literal types.
- TypeScript Narrowing — Refine union types with typeof, instanceof, in, equality and type predicates.
- TypeScript Functions — Type parameters, return values, optional and default parameters, and function types.
- TypeScript Function Overloads — Give one function several call signatures.
- TypeScript any, unknown and never — The escape hatch, the safe top type and the empty type.
- TypeScript History & Versions — Why Microsoft created TypeScript, how it grew into the default way to write large JavaScript apps, every major release on one timeline (including the native Go compiler in 7.0), and which version to use today.
Classes and Enums
- TypeScript Classes — Typed fields, access modifiers, parameter properties, abstract classes and implements.
- TypeScript Enums — Numeric and string enums — and why union types are often a better choice.
Generics and Type Manipulation
- TypeScript Generics — Write reusable functions, interfaces and classes that keep their types.
- TypeScript Utility Types — Partial, Required, Readonly, Pick, Omit, Record, ReturnType and friends.
- TypeScript keyof, typeof and Indexed Access — Derive types from values and from other types.
- TypeScript Mapped and Conditional Types — Transform every property with mapped types, and choose types with conditions.
- TypeScript Discriminated Unions — Model states safely with a shared literal tag.
- TypeScript Type Assertions and satisfies — as, non-null assertions, as const and the satisfies operator.
TypeScript in Practice
- TypeScript Null Safety — strictNullChecks, optional chaining, nullish coalescing and noUncheckedIndexedAccess.
- TypeScript Async and Promises — Type async functions, Promise<T>, fetch responses and errors in catch.
- TypeScript Modules and Declaration Files — import and export types, .d.ts files and @types packages.
- TypeScript Next Steps — Use TypeScript with React and Node.js, and practise for interviews.