Setup and Why TypeScript

Why Use TypeScript

  • Catches mistakes before running: wrong prop names, missing props, wrong types.
  • Autocomplete for props, state and API data in the editor.
  • Safer refactoring in large codebases; it is the standard in most React jobs.

Example

Create a React + TypeScript project:

npm create vite@latest my-app -- --template react-ts

Files use .tsx for components (JSX) and .ts for plain logic. Settings live in tsconfig.json.