LearnThatStack Ace your next interview
TypeScript · question
Question 2 of 102

How do you compile TypeScript code?

beginner
← All TypeScript questions
Re-explain

You compile TypeScript with tsc, the TypeScript compiler. It type-checks your .ts files and emits plain .js files that run in any JavaScript environment.

# Install TypeScript globally
npm install -g typescript

# Compile a single file
tsc app.ts

# Compile with watch mode
tsc app.ts --watch

# Compile using tsconfig.json
tsc

Running tsc with no file names finds the nearest tsconfig.json and compiles the whole project with its settings. Naming a file, as in tsc app.ts, compiles just that file with default options. Since TypeScript 6.0 that is an error when a tsconfig.json is present, unless you add --ignoreConfig. Adding --watch recompiles whenever a file changes.

In many projects tsc only type-checks. A bundler such as Vite strips the types and builds the output, and tsc --noEmit runs separately as the type check. Node.js can also run a .ts file directly by stripping its types, but it does no type checking at all.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the TypeScript cheatsheet.

← Back to all TypeScript questions
Pro · $10/mo

86 of 102 TypeScript answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime