TypeScript

Static Type Checking with TypeScript

Dynamic checking happens while the program runs: a prop arrives as a string where a number was expected, and something downstream throws, on a user's machine, weeks later. Static checking happens first, from the source text alone. React 7,897 suits it unusually well: an application is a graph of function calls whose arguments are written as JSX attributes — exactly where a mistake is easy to make and hard to see.

Type checking options for React and where each stands
System How it checks Status in 2026
PropTypes 4,446 At runtime, in development Inert since React 19
Flow Statically, Meta's own checker Niche; mostly inside Meta
TypeScript Statically, at compile time The default for new projects

Front-End Web Development covers the language itself; what follows is the vocabulary React adds.

Scaffolding a React project with TypeScriptShell
npm create vite@latest my-app -- --template react-ts

The template gives you .tsx sources, a root tsconfig.json referencing one config for application code and one for vite.config.ts, and @types/react with @types/react-dom. Those two matter most: React ships no types of its own, so the @types/react version decides what your JSX means — keep its major in step with React's. Then change two things. The config leaves strict off, without which null is assignable to everything, so add "strict": true; and it pins TypeScript 6 rather than 7.0, the Go rewrite of the compiler.

Subsections