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.tsfor 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
- Docs: https://www.typescriptlang.org/docs
- GitHub: https://github.com/microsoft/TypeScript
- License: Apache 2.0