Est. 2012 Beginner

TypeScript

A typed superset of JavaScript that compiles to plain JavaScript, adding static types and modern features.

Created by Microsoft (Anders Hejlsberg)

Paradigm Multi-paradigm: Object-Oriented, Functional, Imperative
Typing Static, Strong, Structural, Optional
First Appeared 2012
Latest Version TypeScript 5.7 (2024)

TypeScript is a typed superset of JavaScript developed by Microsoft. Every valid JavaScript program is also valid TypeScript, but TypeScript adds optional static types, classes, interfaces, and other features that make large-scale JavaScript development more manageable.

History & Origins

TypeScript was created by Anders Hejlsberg, the legendary language designer behind Turbo Pascal, Delphi, and C#. By 2010, Microsoft saw that JavaScript was becoming the dominant language for web development, but large JavaScript codebases were difficult to maintain.

Google had faced similar challenges and created Closure Compiler with type annotations in comments. Google also proposed adding optional types to JavaScript itself (the abandoned “Traceur” project). Microsoft took a different approach: create a new language that compiles to JavaScript.

The Problem TypeScript Solves

JavaScript, despite its ubiquity, has significant challenges at scale:

  • No static types: Errors caught at runtime, not compile time
  • Weak tooling: Limited autocomplete, refactoring, and navigation
  • Documentation burden: JSDoc comments are optional and often wrong
  • Refactoring risk: Renaming a function might break code anywhere

TypeScript addresses these directly:

  • Static type checking: Catch errors before running code
  • Rich IDE support: Autocomplete, go-to-definition, refactoring
  • Self-documenting: Types serve as verified documentation
  • Safe refactoring: The compiler finds all affected code

Rise to Prominence

TypeScript grew slowly at first. Many JavaScript developers were skeptical of types and Microsoft technology. The turning point came in 2016-2017:

  1. Angular 2 (2016): Google chose TypeScript for Angular, not their own Dart
  2. VS Code (2015-2016): Microsoft’s hit editor, written in TypeScript, proved the concept
  3. React community adoption: DefinitelyTyped provided types for React
  4. Vue 3 (2020): Vue.js rewrote their core in TypeScript

By 2024, TypeScript is the dominant choice for new JavaScript projects:

  • Most major frameworks have TypeScript support
  • npm packages commonly ship with type definitions
  • Many companies require TypeScript for new projects

Why TypeScript Succeeded

  1. Gradual adoption: Add types incrementally, file by file
  2. JavaScript compatibility: All JS is valid TS; use existing code
  3. Excellent tooling: Outstanding IDE support from day one
  4. Open source: MIT licensed, community-driven development
  5. Anders Hejlsberg: Credibility from the C# creator
  6. Structural typing: More flexible than Java/C# nominal typing

TypeScript’s Type System

TypeScript uses structural typing (duck typing with static checks):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
interface Point {
    x: number;
    y: number;
}

// This works - the object has the right shape
const p: Point = { x: 10, y: 20 };

// This also works - extra properties are OK in some contexts
function printPoint(point: Point) {
    console.log(`(${point.x}, ${point.y})`);
}

Key type system features:

  • Union types: string | number
  • Intersection types: A & B
  • Generics: Array<T>, Promise<T>
  • Mapped types: Transform types programmatically
  • Conditional types: T extends U ? X : Y
  • Template literal types: Type-safe string manipulation

Modern TypeScript

TypeScript 5.x brought significant improvements:

  • Decorators: Stage 3 ECMAScript decorators
  • const type parameters: <const T>
  • Performance: Faster builds and type checking
  • Module resolution: Better ESM and bundler support

The language continues evolving to support new JavaScript features while adding type system capabilities.

TypeScript vs. JavaScript

FeatureTypeScriptJavaScript
Type checkingStatic, compile-timeDynamic, runtime
IDE supportExcellent autocomplete/refactoringLimited without JSDoc
Learning curveSteeper initiallyLower barrier to entry
Build stepRequired (tsc)Optional
RuntimeCompiles to JavaScriptRuns directly
Null safetyStrict null checks availableNo built-in checks

TypeScript compiles away to JavaScript—there’s no TypeScript runtime. This means:

  • No runtime overhead
  • Runs anywhere JavaScript runs
  • Can target any JavaScript version (ES5, ES6, ESNext)

The TypeScript Ecosystem

TypeScript has a rich ecosystem:

  • DefinitelyTyped: Community-maintained type definitions for JS libraries
  • ts-node: Run TypeScript directly without pre-compilation
  • tsx: Modern, fast TypeScript execution
  • tsc: The official TypeScript compiler
  • ESLint: TypeScript-aware linting with @typescript-eslint

Most modern tools have first-class TypeScript support: Vite, esbuild, SWC, Bun, and Deno all handle TypeScript natively.

The TypeScript Community

TypeScript has a welcoming community focused on practical solutions:

  • GitHub: Active development and issue discussion
  • TypeScript Discord: Community help and discussion
  • TS Conf: Annual conference
  • Weekly releases: Rapid iteration on features

Microsoft maintains TypeScript as a genuinely open source project, accepting community contributions and engaging with feedback through the RFC process.

Timeline

2010
Microsoft begins internal development of TypeScript
2012
TypeScript 0.8 publicly released, open-sourced on CodePlex
2014
TypeScript 1.0 released at Microsoft Build conference
2016
TypeScript 2.0 with null safety and control flow analysis
2017
Google adopts TypeScript for Angular development
2018
TypeScript 3.0 with project references and tuple improvements
2020
TypeScript 4.0 with variadic tuple types and labeled tuples
2023
TypeScript 5.0 with decorators and const type parameters
2024
TypeScript 5.7 with path rewriting and faster builds

Notable Uses & Legacy

Visual Studio Code

Microsoft's popular editor is written entirely in TypeScript, showcasing large-scale TypeScript development.

Angular

Google's web framework is built with and requires TypeScript, driving enterprise adoption.

Deno

Ryan Dahl's modern JavaScript runtime has first-class TypeScript support without compilation.

Slack Desktop

Slack migrated their Electron-based desktop app to TypeScript for improved maintainability.

Airbnb

Adopted TypeScript across their frontend codebases for type safety at scale.

Stripe

Uses TypeScript extensively for their dashboard and developer tools.

Language Influence

Influenced By

JavaScript Java C# ActionScript

Influenced

Deno AssemblyScript Flow (inspired competition)

Running Today

Run examples using the official Docker image:

docker pull node:22-alpine

Example usage:

docker run --rm -v $(pwd):/app -w /app node:22-alpine sh -c 'npx -y ts-node hello.ts'

Topics Covered

Last updated: