tsconfig Basics
Generate a config
In a project folder with TypeScript installed, create a starter config.
npx tsc --init
Set common options
Start with strict checking and clear input/output folders.
{
"compilerOptions": {
"target": "ES2020",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": "src",
"outDir": "dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src"]
}
Compile the project
With a tsconfig present, run tsc with no file arguments.
tsc
Useful flags to know
strictenables a bundle of safer checksnoImplicitAnyforbids silent anylibchooses built-in type libraries (ES, DOM)- Adjust
moduleto match Node ESM or your bundler
Comments
One comment per signed-in account. Comments are saved with this page’s URL.