Skip to the solution
EasyFrontend11 min read

What is tsconfig.json and which options matter most?

545 views

The problem

Question presented to candidate: "What is tsconfig.json for, and if you were setting up a new project, which compiler options would you actually care about and why?"

What a strong answer should cover:

  • tsconfig.json marks the project root and is read by both tsc and the editor; include, exclude, files, extends, references
  • strict (always on) and extra checks such as noUncheckedIndexedAccess
  • The environment options and how they differ: target changes emitted syntax, lib only changes which APIs the checker knows, module and moduleResolution describe imports
  • Output options: outDir/rootDir, declaration, sourceMap, noEmit when a bundler builds the code, plus skipLibCheck for speed
  • Defaults change across versions (tsc --init in 5.9, compiler defaults in 6.0), so set key options explicitly and inspect with tsc --showConfig

Clarifying questions expected:

  • Is this an app built by a bundler, or code that tsc compiles for Node.js or a published library?
  • Which runtime and JavaScript version must the output support?

Code / implementation expected: Optional β€” a short tsconfig for a stated kind of project, with each option justified.

  • tsconfig
  • tooling

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

11 min read Β· 11 sections

Run the code

Edit the code and run it here. Each console line with an expected value becomes a test.

TypeScriptlib only changes types: an ES2023 method under lib ES2022

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 9 of 81 in TypeScript

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

Up nextEasy

How do you type functions: optional, default and rest parameters?

Continue