Skip to content

tsc and tsconfig.json — the options that matter

Level: 201 · for anyone setting up a TypeScript project

Stub — an outline, not a lesson. There is no runnable example behind this page yet, so nothing on it has been through the check that backs every other claim in this library. The questions below are what the finished page has to answer.

One line: tsc with no file names checks the project tsconfig.json describes; tsc app.ts beside that file stops with TS5112, because naming files means ignoring the config, and TypeScript 7 makes you say so with --ignoreConfig.

Keywords: tsc, tsconfig.json, --showConfig, --ignoreConfig

What the finished page will answer

  • What does tsc app.ts do when a tsconfig.json sits in the same folder, and what do tsc alone and tsc --ignoreConfig app.ts do instead?
  • Which defaults changed in TypeScript 6 and 7, for strict, target, module, types and rootDir, and what does an empty compilerOptions check now?
  • Why is process 'Cannot find name' (TS2591) until types lists node, even with @types/node installed?
  • What does --showConfig print for a config that extends another, and why does it leave the defaults out?
  • Which options does this library's tsconfig.json set, noEmit, erasableSyntaxOnly, verbatimModuleSyntax and allowImportingTsExtensions, and what mistake does each one catch?
  • What do the removed options, such as target: es5, baseUrl and moduleResolution: node, report now?

Examples it will need

  • tsc_and_tsconfig_file_or_project_sh.sh — TS5112 for tsc app.ts beside a tsconfig.json, then the project check and the --ignoreConfig check, each with its exit status
  • tsc_and_tsconfig_defaults_sh.sh — the errors TypeScript 7 gives a small file under an empty tsconfig.json (implicit any, null, unknown process), and how "types": ["node"] and "strict": false change them
  • tsc_and_tsconfig_show_config_sh.sh — tsc --showConfig for a tsconfig that extends another, showing the merged options and no defaults

See also

Sources to start from