Skip to content

Chapter 1 of 8

Introduction to TypeScript & Setup

TypeScript is a statically typed superset of JavaScript developed by Microsoft. Because it builds on top of JavaScript, every valid JavaScript file is also a valid TypeScript file, but TypeScript adds optional static typing, interfaces, classes, and modules to improve scalability, maintainability, and developer productivity. TypeScript code itself cannot be executed directly; instead, the TypeScript compiler transpiles it into plain JavaScript that runs in any JavaScript environment such as browsers, Node.js, or Deno.

To start using TypeScript, you install it through npm, either globally with npm install -g typescript or as a project-local development dependency with npm install typescript --save-dev. You can verify a successful installation by running tsc --version. The compiler is invoked with the tsc command: tsc file.ts compiles a single file, while running tsc alone compiles every file in the project according to the project's configuration.

Project-level configuration lives in a file called tsconfig.json. This JSON file specifies compiler options such as the target JavaScript version (for example, ES5, ES2015, or ESNext), the module system to use, and the strictness mode that governs type-checking behavior. By tailoring tsconfig.json, teams control how their TypeScript projects are compiled without having to pass flags on the command line for every build.

All chapters
  1. 1Introduction to TypeScript & Setup
  2. 2Basic Types & Type System Fundamentals
  3. 3Functions & Collection Types
  4. 4Interfaces, Type Aliases & Object Shapes
  5. 5Classes & Object-Oriented Programming
  6. 6Generics for Reusable Code
  7. 7Modules & Advanced Type-Level Features
  8. 8Strict Mode & Interoperability with JavaScript

Drill it

Reading is not remembering. These come from the Typescript Essentials deck:

Q

What is TypeScript?

TypeScript is a statically typed superset of JavaScript developed by Microsoft that compiles to plain JavaScript code. It adds optional static typing, interface...

Q

How does TypeScript relate to JavaScript?

TypeScript is a superset of JavaScript, meaning all valid JavaScript code is also valid TypeScript. TypeScript code is transpiled to JavaScript, allowing it to...

Q

How do you install TypeScript?

Install TypeScript globally using npm install -g typescript or locally as a dev dependency with npm install typescript --save-dev. Verify installation with tsc...

Q

What is the TypeScript compiler command?

The TypeScript compiler is invoked with tsc. Use tsc file.ts to compile a single file or tsc to compile based on tsconfig.json.