@mikecbrant/tsconfig
v0.1.0
Published
Shareable TypeScript presets for modern ESM Node projects. This package exports three JSON/JSONC presets that downstream projects can extend via the `tsconfig.json` `extends` field:
Readme
@mikecbrant/tsconfig
Shareable TypeScript presets for modern ESM Node projects. This package exports three JSON/JSONC presets that downstream projects can extend via the tsconfig.json extends field:
@mikecbrant/tsconfig/base@mikecbrant/tsconfig/node-library@mikecbrant/tsconfig/node-test
Baseline and assumptions
- Runtime: Node 22 (ES2023). This matches the repository
engines.nodeand the roottsconfig.jsonbaseline discussed in PR #1. - File format: JSON/JSONC is intentionally used for
tsconfigfiles. The TypeScript compiler resolves only JSON/JSONC viaextends; JS/ESM (.mjs) tsconfig files are not supported bytsc, so keeping JSON/JSONC ensures consumers can extend these presets reliably.
Presets
base.json → @mikecbrant/tsconfig/base
Intended for ESM Node codebases as a strict, no‑emit baseline that you can extend in apps or libraries.
Key options (as defined in this preset):
target:ES2023lib:["ES2023"]module:ESNextmoduleResolution:BundlerverbatimModuleSyntax:truestrict:trueexactOptionalPropertyTypes:truenoUncheckedIndexedAccess:truenoImplicitOverride:trueuseDefineForClassFields:trueresolvePackageJsonExports/resolvePackageJsonImports:trueskipLibCheck:truenoEmit:true
node-library.json → @mikecbrant/tsconfig/node-library
For publishable Node libraries that produce .d.ts files.
Differences vs base:
- Enables declaration output:
declaration: true,declarationMap: true - Allows emitting build output:
noEmit: false(inherits all strictness frombase)
Typical consumers will also set outDir, rootDir, and include/exclude to match their project layout.
node-test.json → @mikecbrant/tsconfig/node-test
For Node test code. Extends base and preloads common test type packages.
Differences vs base:
- Adds
types:["node", "vitest", "vitest/globals"] - Keeps
noEmit: true
Consumers can replace or augment the types array if they use a different runner.
Usage
Extend a preset from your project tsconfig.json:
App or library baseline (no emit):
{
"extends": "@mikecbrant/tsconfig/base",
"compilerOptions": {
// project-specific options here (paths/outDir/isolatedModules/etc.)
},
"include": ["src/**/*.ts"],
"exclude": ["dist", "node_modules"],
}Node library (generate declarations):
{
"extends": "@mikecbrant/tsconfig/node-library",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
},
"include": ["src/**/*.ts"],
"exclude": ["dist", "node_modules", "**/*.test.ts"],
}Node tests:
{
"extends": "@mikecbrant/tsconfig/node-test",
"compilerOptions": {
// add any runner-specific types if needed
},
"include": ["src/**/*.test.ts", "tests/**/*.ts"],
}Compatibility notes
- ESM-first: The presets assume ESM (
module: ESNext) withmoduleResolution: BundlerandverbatimModuleSyntax: true. Prefer explicittype-only imports and avoid deep CJS interop. - JSON/JSONC only: Presets are published as JSON; this is by design for
tsccompatibility when usingextends. - TypeScript peer:
typescript >=5.6is required by consumers.
If you need to diverge (e.g., CommonJS, different types for tests, or a stricter/looser lib target), override those fields in your project’s tsconfig.json.
