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.tsdo when atsconfig.jsonsits in the same folder, and what dotscalone andtsc --ignoreConfig app.tsdo instead? - Which defaults changed in TypeScript 6 and 7, for
strict,target,module,typesandrootDir, and what does an emptycompilerOptionscheck now? - Why is
process'Cannot find name' (TS2591) untiltypeslistsnode, even with@types/nodeinstalled? - What does
--showConfigprint for a config thatextendsanother, and why does it leave the defaults out? - Which options does this library's
tsconfig.jsonset,noEmit,erasableSyntaxOnly,verbatimModuleSyntaxandallowImportingTsExtensions, and what mistake does each one catch? - What do the removed options, such as
target: es5,baseUrlandmoduleResolution: node, report now?
Examples it will need¶
-
tsc_and_tsconfig_file_or_project_sh.sh— TS5112 fortsc app.tsbeside a tsconfig.json, then the project check and the--ignoreConfigcheck, 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, unknownprocess), and how"types": ["node"]and"strict": falsechange them -
tsc_and_tsconfig_show_config_sh.sh—tsc --showConfigfor a tsconfig that extends another, showing the merged options and no defaults
See also¶
strict— the eight checks the defaultstrictturns on- Running TypeScript — why
noEmitis enough when Node runs the .ts file - Module resolution — what
moduleandmoduleResolutiondecide - Types for packages — the
@typespackages thattypesnow has to name npm runandnpx— running the pinnedtscfrom node_modules- Rust: What
cargo run -vshows: therustcline, flag by flag ↗ — a project file turned into compiler flags, printed by Cargo - Python:
pyproject.toml↗ — the Python project file that plays the same part