Lesson 1 +10 XP

Getting Started with TypeScript

What is TypeScript?

TypeScript is a typed superset of JavaScript created by Microsoft. It adds static typing to JavaScript and compiles down to plain JavaScript that runs in any browser or Node.js environment.

Key Benefits

FeatureDescription
Catch Errors EarlyUncovers type errors at compile time rather than runtime.
Enhanced ToolingProvides auto-completion, refactoring, and inline docs in IDEs.
Clear DocumentationType definitions serve as explicit code documentation.
Modern JS FeaturesSupports latest ECMAScript proposals compiled to older targets.

Installing and Running TypeScript

You can install the TypeScript compiler (tsc) globally or locally using npm:

npm install -g typescript

To compile a TypeScript file (.ts) to JavaScript (.js):

tsc index.ts

This creates index.js which can be executed in any JavaScript engine.

TL;DR

  • TypeScript is a typed superset of JavaScript.
  • TypeScript code is compiled to JavaScript via the tsc compiler.
  • It catches errors early at compile time and improves developer productivity.