What Is TypeScript?

TypeScript is a programming language developed and maintained by Microsoft.

It is a strict syntactical superset of JavaScript that adds optional static typing to the language.

image.png

How Does TypeScript Code Run?

TypeScript code never runs directly in your browser. Your browser can only understand javascript.

  1. JavaScript is the runtime language that actually executes in your browser or Node.js environment
  2. TypeScript compiles down to JavaScript before execution
  3. During compilation, TypeScript performs type checking (similar to C++). If any type errors are detected, the conversion to JavaScript fails

image.png

TypeScript Compiler

tsc is the official TypeScript compiler that converts TypeScript code into JavaScript.

Several other popular compilers/transpilers also convert TypeScript to JavaScript. Notable examples include:

  1. esbuild
  2. swc