@lazyconfig/tsconfig
v0.1.0
Published
Reusable TypeScript configuration presets to standardize compiler settings.
Maintainers
Readme
@lazyconfig/tsconfig
Reusable TypeScript configuration presets to standardize compiler settings across projects.
Installation
# pnpm
pnpm add -D @lazyconfig/tsconfig typescript
# npm
npm install --save-dev @lazyconfig/tsconfig typescript
# yarn
yarn add --dev @lazyconfig/tsconfig typescript
# bun
bun add --dev @lazyconfig/tsconfig typescriptRequirements
| Preset | TypeScript | Node.js |
| ------- | ---------- | ------- |
| base | >=5.0 | any |
| node | >=5.0 | >=18 |
| lib | >=5.0 | any |
| react | >=5.0 | any |
- TypeScript
>=5.0is required by all presets —verbatimModuleSyntax(base) andmoduleResolution: "Bundler"(lib, react) were introduced in TS 5.0. - Node.js
>=18is required by thenodepreset —target: "ES2022"withNodeNextresolution targets the Node.js 18+ runtime.
Presets
base (default)
Foundation shared by all other presets. Enables strict type checking and common safety flags.
{
"extends": "@lazyconfig/tsconfig/base"
}or explicitly:
{
"extends": "@lazyconfig/tsconfig/base.json"
}| Option | Value |
| ---------------------------------- | ------ |
| strict | true |
| skipLibCheck | true |
| forceConsistentCasingInFileNames | true |
| esModuleInterop | true |
| verbatimModuleSyntax | true |
verbatimModuleSyntaxenforces that type-only imports useimport type, ensuring safe erasure by single-file transpilers such as Vite, esbuild, and SWC.
node
For Node.js applications and CLI tools. Uses NodeNext module resolution with source maps and declaration output enabled.
{
"extends": "@lazyconfig/tsconfig/node",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"]
}| Option | Value |
| ------------------ | ------------ |
| target | ES2022 |
| lib | ["ES2022"] |
| module | NodeNext |
| moduleResolution | NodeNext |
| declaration | true |
| declarationMap | true |
| sourceMap | true |
| noEmitOnError | true |
NodeNextmodule resolution requires file extensions in relative imports (e.g.import { foo } from './foo.js').
lib
For framework-agnostic libraries consumed by bundlers. Emits only declaration files — the bundler handles the JavaScript output.
{
"extends": "@lazyconfig/tsconfig/lib",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"]
}| Option | Value |
| --------------------- | ------------ |
| target | ES2022 |
| lib | ["ES2022"] |
| module | ESNext |
| moduleResolution | Bundler |
| declaration | true |
| declarationMap | true |
| emitDeclarationOnly | true |
| noEmitOnError | true |
react
For React applications. Adds DOM types and enables the automatic JSX transform. Delegates all emit to the bundler.
{
"extends": "@lazyconfig/tsconfig/react",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src"]
}| Option | Value |
| ------------------ | ----------------------------------- |
| target | ES2022 |
| lib | ["DOM", "DOM.Iterable", "ES2022"] |
| module | ESNext |
| moduleResolution | Bundler |
| jsx | react-jsx |
| noEmit | true |
DOM.Iterableis included sofor...ofover DOM collections (NodeList,HTMLCollection, etc.) type-checks correctly.
Path aliases (e.g.
@/) requirebaseUrlandpathsin your project's owntsconfig.json. The bundler also needs its own alias configuration (e.g.resolve.aliasin Vite).
env.d.ts — build-time constants
Provides ambient type declarations for constants injected by bundlers at build time.
{
"compilerOptions": {
"types": ["@lazyconfig/tsconfig/env"]
}
}| Constant | Type | Description |
| ---------- | --------- | --------------------------------------------------- |
| __DEV__ | boolean | true in development builds, false in production |
| __PROD__ | boolean | true in production builds, false in development |
License
MIT
