Generate a tsconfig.json that fits your project
tsconfig.json controls how the TypeScript compiler interprets and emits your
code. The right settings differ sharply between a Node service, a React app
compiled by a bundler, and a library you publish to npm. This builder asks what
you are building and produces a sensible, modern configuration with the correct
target, module, moduleResolution, strictness flags, and output options.
How it works
The output is a single compilerOptions object plus include/exclude arrays.
The builder selects defaults by project type:
- Node app —
module: "nodenext",moduleResolution: "nodenext", emit enabled tooutDir. - React / bundler —
module: "esnext",moduleResolution: "bundler",jsx: "react-jsx", andnoEmit: truebecause the bundler emits. - Library — emit enabled with
declaration: trueanddeclarationMap: trueso consumers get type definitions and go-to-definition.
Strictness layers on top. A typical strict config looks like:
{
"compilerOptions": {
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
}
}
Path aliases are written as a baseUrl plus a paths map. Remember the aliases
must also be configured in your runtime or bundler — tsconfig only teaches the
type-checker about them.
Tips and notes
- Prefer
strict: trueon every new project; loosening individual flags later is easier than retrofitting strictness onto a large untyped codebase. - For bundler projects keep
noEmit: trueand let Vite/esbuild/webpack produce output, usingtsc --noEmitpurely as a type-check step in CI. skipLibCheck: truespeeds up builds by trusting third-party.d.tsfiles; it is widely used and safe in practice.- A published library should set
declaration: trueso downstream users get full IntelliSense.