@zemd/tsconfig
v2.0.0
Published
Shared default tsconfig for my projects
Maintainers
Readme
@zemd/tsconfig
Shared TypeScript configs with strict defaults for React libraries, Next.js apps, and Node.js projects.
Configs
| Config | Target | Module | Key features |
| --------------------- | ------ | ------------------ | ------------------------ |
| tsconfig-react.json | ESNext | ESNext (Bundler) | JSX, DOM types |
| tsconfig-next.json | ESNext | Preserve (Bundler) | Next.js plugin, noEmit |
| tsconfig-node.json | ES2025 | NodeNext | Node.js types |
All configs extend tsconfig-base.json which enables strict mode, verbatimModuleSyntax, isolatedDeclarations, erasableSyntaxOnly, and other strict checks.
Install
npm install @zemd/tsconfig --save-devUsage
React library
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@zemd/tsconfig/tsconfig-react.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"]
}Next.js app
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@zemd/tsconfig/tsconfig-next.json",
"include": ["next-env.d.ts", "src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules", ".next"]
}Node.js project
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@zemd/tsconfig/tsconfig-node.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}Monorepo
In a monorepo, use a solution-style root tsconfig.json that references each package. Each package then extends the appropriate config and enables composite for project references.
Root tsconfig.json — does not compile anything, only wires packages together:
{
"files": [],
"references": [
{ "path": "packages/ui" },
{ "path": "packages/utils" },
{ "path": "packages/web" }
]
}packages/ui/tsconfig.json — a React component library:
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@zemd/tsconfig/tsconfig-react.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules", "dist"],
"references": [
{ "path": "../utils" }
]
}packages/utils/tsconfig.json — a shared Node.js utility package:
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@zemd/tsconfig/tsconfig-node.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist"]
}Then build the entire project graph with:
tsc --buildTip: The base config already enables
declaration,declarationMap, andisolatedDeclarations— which means fast, parallelizable declaration emit and full cross-package IDE navigation out of the box.
Compatibility
These configs target the latest LTS Node.js (currently Node.js 24) and are designed for TypeScript 6.0+, with the latest versions of React and Next.js in mind. If you're on an older Node.js or TypeScript version, you may need to adjust target, module, or lib settings in your own tsconfig.json.
Notes
- You must set
outDirandrootDiryourself - TypeScript treats these as relative paths, so they should live in your owntsconfig.json. - When extending
tsconfig-next.json, make surenext-env.d.tsis in theincludearray (it is by default). If you overrideinclude, add it back manually. - The base config includes
watchOptionsthat usesuseFsEventsOnParentDirectoryand excludes**/node_modules,dist, andtmpdirectories. To extend or override, add your ownwatchOptionsin yourtsconfig.json:{ "watchOptions": { "excludeDirectories": ["**/node_modules", "dist", "tmp", ".next"] } }
License
@zemd/tsconfig is released under the MIT license.
