TypeScript for Beginners
For those who know JavaScript basics. Types and inference, unions and narrowing, object types and interfaces, functions, classes, generics, utility types, async code and setting up a project.
The course has no coding exercises, so you need nothing installed to take it. To try the lesson examples, open them in the TypeScript Playground in your browser, or set up your computer in three steps.
Try the Playground
The TypeScript Playground checks your code as you type, shows the JavaScript the compiler writes from it and runs it. Strict mode is on there, as in the course.
Install Node.js
Pick the LTS version of Node.js, 22.18 or newer.
- Download the installer for your system from nodejs.org/en/download and run it.
- The guide Running TypeScript natively shows how Node.js runs a
.tsfile: it removes the types and does not check them.
Install TypeScript and VS Code
The compiler
tscis what checks the types. The course uses TypeScript 7.- The page Download TypeScript shows how to add it to your computer or to a project.
- VS Code understands TypeScript out of the box and underlines type errors as you type: see TypeScript in Visual Studio Code.
Syllabus
- Narrowing with typeofTheory
- Quiz — the type after returnQuiz
- Null checks and equalityTheory
- Quiz — zero in a conditionQuiz
- The in and instanceof checksTheory
- Quiz — the in operatorQuiz
- Discriminated unionsTheory
- Quiz — a discriminated unionQuiz
- Exhaustiveness with neverTheory
- Quiz — a forgotten caseQuiz
- User-defined type guardsTheory
- Quiz — a wrong checkQuiz
- InterfacesTheory
- Quiz — an interfaceQuiz
- Extending and intersectingTheory
- Quiz — | and &Quiz
- Structural typingTheory
- Quiz — shape, not nameQuiz
- Excess properties in a literalTheory
- Quiz — a literal and a variableQuiz
- Index signaturesTheory
- Quiz — a missing keyQuiz
- type or interfaceTheory
- Quiz — two interfaces of one nameQuiz
- Parameters and the resultTheory
- Quiz — calling a functionQuiz
- Optional, default and rest parametersTheory
- Quiz — ? or a default valueQuiz
- Function typesTheory
- Quiz — function types and voidQuiz
- Callbacks and contextual typingTheory
- Quiz — a callback with one parameterQuiz
- Function overloadsTheory
- Quiz — an overload and a unionQuiz
- Fields and the constructorTheory
- Quiz — a field with no valueQuiz
- public, private and # fieldsTheory
- Quiz — private at run timeQuiz
- readonly and parameter propertiesTheory
- Quiz — parameter propertiesQuiz
- get, set and staticTheory
- Quiz — staticQuiz
- InheritanceTheory
- Quiz — an overridden methodQuiz
- abstract and implementsTheory
- Quiz — implements and extendsQuiz