Project configuration basics
Concept and syntax
Use a tsconfig.json at the project root to collect compilation settings. In this lesson use {"compilerOptions":{"strict":true,"target":"ES2022","module":"commonjs","outDir":"dist","noEmitOnError":true},"include":["src/**/*.ts"]}. Save the example as src/main.ts; tsc -p . builds using this configuration and node dist/main.js runs the result. The include pattern selects matching root files; imports can add dependencies beyond that pattern. Passing source filenames directly to tsc does not use this project configuration. The strict setting enables a family of stricter checks.
Working example
Use the project files and commands described above, not the standalone command.
Expected output (one line per log):
9Common mistake
Intentionally invalid; check this snippet separately. Do not run it.
Expected compiler diagnostic: TS7006. Under strict checking an untyped parameter with no contextual type triggers implicit any. Annotate n as number.
Practice and recap
Create a separate file outside src containing an incompatible assignment. Run tsc -p . and explain why the unimported file is not checked.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Project configuration basics — knowledge check
Check the concept, apply it to a new choice, and interpret a compiler diagnostic.
Which command selects this project configuration?
What is include used for?
Why does the parameter n need attention in this project?
function inc(n) { return n + 1; }console.log(inc(2));