How to use the tsconfig generator
- Choose the Project type: Node.js app (NodeNext), Library with type declarations, Web app with a bundler (Vite), React with Vite, or Next.js.
- Leave Extra strictness (noUncheckedIndexedAccess …) ticked for new code; untick it for an older codebase.
- Tick @/ path alias to ./src/** if you import with
@/components/..., and Type-check JavaScript files too for mixed projects. - For Node.js and library presets, set the Source folder and Output folder. A Node.js app can also Emit .d.ts declarations.
- Save the output as
tsconfig.jsonin the project root and runnpx tsc --noEmitto test it.
What it does and when to use it
tsconfig.json tells the TypeScript compiler which files to check, how strict to be and what kind of JavaScript to produce. Many copied examples online still contain options that newer releases reject. This tool writes a current file for the five common project shapes.
Use it for a new project or when an upgrade starts showing deprecation errors. A Node.js project also needs a package.json with a build: tsc script, and linting comes from the ESLint config generator with its TypeScript option. To type JSON data you already have, try JSON to TypeScript.
How it works
All presets share a strict core: target: ES2022, strict, skipLibCheck, isolatedModules, resolveJsonModule and forceConsistentCasingInFileNames. The presets differ in a few places:
| Preset | module / resolution | lib | Output |
|---|---|---|---|
| Node.js app, Library | NodeNext / NodeNext | ES2023 | rootDir → outDir, source maps |
| Vite, React | ESNext / Bundler | ES2023, DOM | noEmit (Vite builds) |
| Next.js | ESNext / Bundler | ES2023, DOM | noEmit, next plugin |
React uses jsx: react-jsx; Next.js uses jsx: preserve and turns off verbatimModuleSyntax. The Library preset always adds declaration and declarationMap. Each option is explained in the TSConfig reference.
Worked examples
Node.js app with the defaults. The file starts:
"target": "ES2022",
"lib": [
"ES2023"
],
"module": "NodeNext",
"moduleResolution": "NodeNext",
with rootDir src, outDir dist and "sourceMap": true.
React with a path alias. Preset React with Vite, alias ticked, Extra strictness off. You get "moduleResolution": "Bundler", "jsx": "react-jsx", "types": ["vite/client"], "noEmit": true and a paths entry mapping @/* to ./src/*.
A library in lib/ built to build/. Preset Library, source lib, output build. The file includes lib, writes to build, and adds "declaration": true and "declarationMap": true.
Limits and tips
- An alias is not enough for Vite. Vite needs the same
@alias, which the Vite config generator can add, or imports fail at build time. - Monorepos with project references need extra settings (
composite,references) that are not generated. - Test with
npx tsc --showConfigto see the final settings TypeScript will use.
Frequently asked questions
Why is there no baseUrl in the file?
Why does the file list "types" explicitly?
What does Extra strictness add?
Which preset should I pick for an Express or Fastify server?
Why does the Next.js preset set noEmit?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.