0Pricing
TypeScript Academy · Lesson

What TypeScript Adds to JavaScript

Learn how TypeScript extends JavaScript with static types.

What TypeScript Adds to JavaScript is a free TypeScript Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Welcome

TypeScript is a superset of JavaScript that adds static type annotations. In this lesson you'll learn exactly what TypeScript contributes on top of plain JavaScript.

TypeScript Is a Superset

Every valid JavaScript file is valid TypeScript. You can rename a .js file to .ts and it will compile. TypeScript only adds features on top — it never removes JavaScript syntax.

Type Annotations

The most visible addition is type annotations. You declare the type of a variable, parameter, or return value after a colon.
let name: string = 'Alice';
let age: number = 30;
let active: boolean = true;

Compile-Time Type Checking

TypeScript checks types before your code runs. If you assign the wrong type, the compiler reports an error — not a runtime crash.
let count: number = 5;
count = 'hello'; // Error: Type 'string' is not assignable to type 'number'

Interfaces and Type Aliases

TypeScript adds interfaces and type aliases to describe object shapes. These exist only at compile time — they produce no JavaScript output.
interface User {
  name: string;
  age: number;
}

const alice: User = { name: 'Alice', age: 30 };

Enums

Enums let you define a set of named constants. Unlike interfaces, enums do emit JavaScript code.
enum Direction { Up, Down, Left, Right }
const move: Direction = Direction.Up;

Generics

Generics let you write code that works with any type while still being type-safe. They are a major TypeScript feature for reusable utilities.
function identity<T>(value: T): T {
  return value;
}
const n = identity<number>(42);

Access Modifiers on Classes

TypeScript adds public, private, and protected to classes. JavaScript has the # syntax for private, but TypeScript's modifiers are checked at compile time.
class BankAccount {
  private balance: number = 0;
  deposit(amount: number) { this.balance += amount; }
}

Non-Nullable Types

With strictNullChecks enabled, null and undefined are not automatically assignable to every type. You must explicitly allow them with union types.
let name: string = null; // Error with strictNullChecks
let maybeName: string | null = null; // OK

TypeScript Erases Types at Runtime

All TypeScript type annotations are removed during compilation. The output is plain JavaScript — there is no type information at runtime.

Better IDE Tooling

With type information, IDEs can provide accurate autocomplete, inline documentation, safe renames, and find-all-references across your entire project.

Quick Check

What happens to TypeScript type annotations when the code is compiled?

Recap

TypeScript extends JavaScript with type annotations, interfaces, enums, generics, and access modifiers. All type information is erased at compile time. The result is safer, more tooling-friendly JavaScript.

Frequently asked questions

Is the “What TypeScript Adds to JavaScript” lesson free?

Yes — the full text of “What TypeScript Adds to JavaScript” is free to read here on the web, and the TypeScript Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO.

What will I learn in “What TypeScript Adds to JavaScript”?

Learn how TypeScript extends JavaScript with static types. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start TypeScript Academy?

No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “What TypeScript Adds to JavaScript” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this TypeScript Academy lesson?

Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. JavaScript Pain Points: Runtime Bugs
  2. What TypeScript Adds to JavaScript
  3. Compiling TypeScript to JavaScript
  4. When to Use TypeScript in Your Projects
← Back to TypeScript Academy