TypeScript

A strongly-typed superset of JavaScript that compiles to plain JS, adding safety to large-scale applications.

Object-Oriented
Functional
Imperative
Intermediate
2012
Anders Hejlsberg (Microsoft)

Overview

TypeScript is a free and open-source programming language developed by Microsoft. It is a strict syntactical superset of JavaScript that adds optional static typing. TypeScript is designed for the development of large applications and transpiles to JavaScript. It offers classes, interfaces, generics, and modules — enabling teams to build robust, maintainable codebases with compile-time safety checks.

Key Features

  • Static typing — Catch bugs at compile time with a powerful type system
  • Type inference — Smart defaults mean you don't have to annotate everything
  • Generics — Write reusable, type-safe code for collections and utilities
  • Interfaces & enums — Define contracts and constant sets
  • Full JS compatibility — Any valid JavaScript is valid TypeScript

Code Example

typescript
// TypeScript generics and interfaces
interface ApiResponse<T> {
  data: T;
  status: number;
  message: string;
}

async function fetchApi<T>(endpoint: string): Promise<ApiResponse<T>> {
  const res = await fetch(endpoint);
  const data: T = await res.json();
  return { data, status: res.status, message: 'OK' };
}

Learning Resources

Learning Path

23 topics across 5 sections

1Basics

Getting started with TypeScript's type system.

2Advanced Types

TypeScript's powerful type-level programming.

3Classes & OOP

Object-oriented TypeScript patterns.

  • Classes — Properties, methods, access modifiers (public/private/protected)
  • Abstract Classes — Abstract methods, base classes, and implementation contracts
  • Decorators — Class, method, and property decorators (stage 3)
  • Mixins — Composable class patterns for code reuse

4Modules & Configuration

Project organization and compiler options.

  • Modules — ES modules, namespace, declaration merging
  • tsconfig.json — Compiler options, strict mode, paths, and project references
  • Declaration Files — .d.ts files, DefinitelyTyped, and writing type definitions
  • Build Tools — tsc, ts-node, tsx, and integration with bundlers

5Advanced Patterns

Real-world TypeScript patterns for production code.

  • Type Guards — typeof, instanceof, in, and custom type predicates
  • Branded Types — Nominal typing patterns for type-safe IDs and units
  • Builder Pattern — Fluent APIs with full type inference
  • Error Handling — Result types, discriminated unions for errors, and exhaustive checks