TypeScript Setup
To use TypeScript you need a few tools.
You need Node.js on your computer.
Node.js lets you run JavaScript outside a browser.
You also need the TypeScript compiler and a config file.
Install the compiler
A compiler turns TypeScript into JavaScript.
The TypeScript compiler is often called tsc.
You install it with npm.
npm is a tool that installs packages.
A package is a ready made pile of code.
Make a tsconfig.json
tsconfig.json is a settings file.
It tells the compiler how strict to be.
It also picks which files to check.
Many tools create this file for you.
Your first .ts file
Write TypeScript in files that end with .ts.
Use .tsx if the file has JSX.
JSX is the HTML like tags you write in React.
Run tsc to make plain .js files.
Tools that set this up for you
Vite and Next.js often wire TypeScript for you.
You still get a tsconfig.json.
You still write .ts and .tsx files.
Knowing the basics helps when something breaks.
Editor support
VS Code and many editors understand TypeScript already.
Red squiggles are the compiler talking to you right away.
Fix them before you even save.
That is how types help every minute you type.
Once tsc runs with no errors, you have a working TypeScript project.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.