Skip to main content

Superset of JavaScript

1. What "superset" means

TypeScript extends the JavaScript language:

  • adds static typing (type annotations, interfaces, generics);
  • introduces new syntax (for example, enum, type, interface);
  • supports future JS features that are not yet implemented in every environment.

At the same time, TypeScript does not change the meaning or behavior of JavaScript code - it only adds a layer of type checking before the program runs.


2. Example: any JS is valid TS

javascript
// Regular JavaScript function sum(a, b) { return a + b; }

This code is perfectly valid in TypeScript too. But in TS you can add types:

javascript
function sum(a: number, b: number): number { return a + b; }

Now the compiler checks that a and b are numbers, and the return value is number as well.


3. How it works "under the hood"

TypeScript files (.ts):

  1. Go through type checking (nothing is executed, only analysis);
  2. Are then transpiled (translated) into plain JavaScript code;
  3. The resulting .js can run in a browser or Node.js, without needing TS at runtime.

4. Why this matters

Thanks to this architecture, TypeScript:

  • is fully compatible with the existing JavaScript ecosystem (npm, Node.js, React, etc.);
  • does not require changing the runtime, engine, or browser;
  • adds a layer of safety and predictability while staying "transparent" for execution.

Summary

TypeScript is a superset of JavaScript, because it includes all of JavaScript + adds typing and new features, while remaining compatible with and compilable to plain JavaScript.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.