Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsApr 11, 2026·3 min de lecture

TypeScript — JavaScript with Syntax for Types

TypeScript is a superset of JavaScript that adds static types, interfaces, generics, and modern ES features, compiled down to plain JavaScript. Created by Anders Hejlsberg at Microsoft. Used by Airbnb, Slack, Asana, and a huge share of modern web projects.

Introduction

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Designed by Anders Hejlsberg (also creator of C# and Turbo Pascal) at Microsoft. First released in 2012, now used in most large-scale web projects. TypeScript makes JavaScript scalable for teams and big codebases by catching type errors at compile time and providing world-class IDE autocomplete and refactoring.

What TypeScript Does

  • Static types — interfaces, type aliases, unions, intersections
  • Generics — parameterized types for reusable code
  • Type inference — infer types from values and signatures
  • Type narrowing — refine types via checks (typeof, instanceof, discriminators)
  • Utility types — Partial, Required, Pick, Omit, Record, Awaited
  • Declaration files.d.ts for typing existing JS libraries
  • Module resolution — classic, node, bundler strategies
  • JSX support — TSX for React, Vue, Solid
  • Project references — incremental builds across packages
  • Strict mode — strict null checks, no implicit any

Architecture

TSC compiler written in TypeScript itself. Parses source to AST, performs type checking using a structural type system, then emits JavaScript. Language Server (tsserver) powers IDE features via LSP.

Self-Hosting

Language tool, ships via npm.

Key Features

  • Structural type system
  • Type inference
  • Generics
  • Discriminated unions
  • Utility types
  • Declaration files for JS libraries
  • JSX/TSX support
  • Project references
  • Incremental builds
  • Rich LSP integration

Comparison

Language Types Compiles To Runtime
TypeScript Static + inference JavaScript Node/Browser/Bun/Deno
Flow Static JavaScript Same
Hegel Static JavaScript Same
ReScript Static JavaScript Same
PureScript Static JavaScript Same
Elm Static JavaScript Browser

FAQ

Q: When should I use TypeScript? A: Any JS project beyond 1000 lines, team size > 1, or long-term maintenance. Small scripts can skip it.

Q: Must I enable strict mode? A: Strongly recommended. Turning off strict mode essentially discards TypeScript's core value. Use @ts-expect-error to annotate temporary exceptions.

Q: Slow compilation? A: v5+ introduces project references and incremental builds. For large projects use tsc -b build mode. You can also use swc or esbuild for transformation only and skip type checking (combined with a separate tsc --noEmit check).

Sources

Discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires