elefcode

tsconfig & package.json Generator

Presets for Next.js, Vite, Node and npm libraries, with strictness options explained — get tsconfig.json and a matching package.json.

Project
Package manager (for scripts)
Tests
Compiler
Module resolution
Strictness
{
  "compilerOptions": {
    "target": "ES2023",
    "lib": [
      "ES2023"
    ],
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true,
    "noFallthroughCasesInSwitch": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "verbatimModuleSyntax": true,
    "moduleDetection": "force",
    "rewriteRelativeImportExtensions": true,
    "erasableSyntaxOnly": true,
    "outDir": "./dist",
    "rootDir": "./src",
    "sourceMap": true
  },
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules",
    "dist",
    "**/*.test.ts"
  ]
}
  • Write relative imports with the .ts extension: import { x } from "./util.ts". Node runs those files directly in dev, and tsc rewrites them to .js in the build. erasableSyntaxOnly rules out enums and namespaces, which Node cannot strip.
  • Version ranges are a starting point — run your package manager’s install to resolve the latest releases.

Advertisement

Guide

About the tsconfig & package.json Generator

tsconfig.json tells the TypeScript compiler which files belong to the project, which JavaScript version to target, how to resolve imports and how strict to be. The defaults from tsc --init are generic; the right settings depend on whether a bundler, a framework or Node itself runs your code.

Pick the kind of project and the generator chooses consistent settings, then explains each strictness flag so you can decide how far to go.

Bundler or NodeNext?

Use Bundler when Vite, Next.js, esbuild or similar resolves your imports: extensionless imports and package exports both work. Use NodeNext when Node runs the compiled output directly, and for libraries, so TypeScript enforces the same rules Node applies at runtime.

Publishing a library

The library preset emits declarations and source maps, and writes an exports map with the types condition first, which TypeScript requires. files limits the published package to the build output, and prepublishOnly builds before every publish.

How to use it

  1. 1Choose Next.js, Vite + React, Node app or npm library.
  2. 2Adjust target, module resolution and output settings.
  3. 3Choose how strict the type checker should be.
  4. 4Download both files into your project root and run your install command.

Frequently asked questions

What is the recommended tsconfig for 2026?

strict: true, noUncheckedIndexedAccess, isolatedModules, verbatimModuleSyntax and skipLibCheck, with module resolution set by who runs the code: Bundler for frameworks, NodeNext for Node and libraries.

Why do I need .js extensions in TypeScript imports?

Under NodeNext, TypeScript does not rewrite import paths, and Node requires full file names in ES modules. Writing ./util.js in a .ts file points at the file that will exist after compiling.

Should I turn on noUncheckedIndexedAccess?

For new code, yes. It makes arr[0] and record[key] possibly undefined, which matches reality and prevents a common class of crashes. Existing projects may need a gradual migration.

What does skipLibCheck do?

It skips type-checking .d.ts files from dependencies. Builds get faster and you avoid errors in third-party types you cannot fix; your own code is still fully checked.

Why does the @/ alias break my compiled Node app?

paths only affects type checking. tsc emits the import unchanged, and Node does not know what @/ means. Bundlers understand it; for plain Node, use package.json subpath imports instead.

What does "type": "module" do?

It makes Node treat .js files in the package as ES modules, so import and export work natively. Use .cjs for any file that must stay CommonJS.

Related tools