@dvashim/typescript-config
v2.0.5
Published
Shared TypeScript configurations
Readme
TypeScript Configurations
Requires TypeScript >= 6.
Installation
npm:
npm install -D @dvashim/typescript-configor pnpm:
pnpm add -D @dvashim/typescript-configConfigurations
| Name | Path | Alias |
| ---- | ---- | ----- |
| Base | @dvashim/typescript-config or @dvashim/typescript-config/base | — |
| Library development | @dvashim/typescript-config/lib/dev or @dvashim/typescript-config/lib-dev | @dvashim/typescript-config/lib |
| Library production | @dvashim/typescript-config/lib/prod or @dvashim/typescript-config/lib-prod | — |
| React JSX application | @dvashim/typescript-config/app/react or @dvashim/typescript-config/app-react | @dvashim/typescript-config/app |
| Vite + React JSX application | @dvashim/typescript-config/app/react/vite or @dvashim/typescript-config/app-react-vite | — |
| Node | @dvashim/typescript-config/node | — |
Use
Base configuration:
// tsconfig.json (base)
// Strict ES2024 + ESM foundation with bundler resolution.
// Enforces verbatim module syntax, erasable-only syntax,
// and maximum type safety (strict, exactOptionalPropertyTypes,
// noUncheckedIndexedAccess, noUnusedLocals, etc.).
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@dvashim/typescript-config",
"include": ["src"]
}Library development configuration:
// tsconfig.json (library development)
// Extends base for library development.
// Enables .d.ts declarations, composite builds,
// source maps, declaration maps, and isolated declarations.
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@dvashim/typescript-config/lib-dev",
"include": ["src"]
}Library production configuration:
// tsconfig.json (library production)
// Extends lib-dev for production builds.
// Strips source maps, declaration maps, comments,
// and @internal declarations for minimal output.
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@dvashim/typescript-config/lib-prod",
"include": ["src"]
}React JSX application configuration:
// tsconfig.json (react jsx application)
// Extends base for React applications.
// Adds DOM + DOM.Iterable + DOM.AsyncIterable libs,
// automatic JSX runtime, esnext modules, and
// .ts/.tsx extension imports.
// No emit — bundler handles output.
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@dvashim/typescript-config/app-react",
"include": ["src"]
}Vite + React JSX application configuration:
// tsconfig.json (vite + react jsx application)
// Extends React config with Vite client types
// (import.meta.env, import.meta.hot, asset imports).
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@dvashim/typescript-config/app-react-vite",
"include": ["src"]
}Node configuration:
// tsconfig.json (node)
// Extends base for Node.js tooling files
// (build configs, scripts). @types/node,
// esnext modules, and .ts extension imports.
// No emit — bundler handles output.
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@dvashim/typescript-config/node",
"include": ["vite.config.ts"]
}Rules
Base configuration
Options listed below are set explicitly. Additional options (strict, moduleResolution: "bundler", noUncheckedSideEffectImports, forceConsistentCasingInFileNames, useDefineForClassFields, esModuleInterop) rely on TypeScript 6 defaults.
Type Checking
- exactOptionalPropertyTypes:
true— Treats optional properties as strictlyT | undefined. - noFallthroughCasesInSwitch:
true— Reports errors for fallthrough cases inswitchstatements. - noImplicitOverride:
true— Requires theoverridekeyword when overriding class members. - noImplicitReturns:
true— Reports errors when not all code paths in a function return a value. - noPropertyAccessFromIndexSignature:
true— Disallows property access via dot notation when defined only by an index signature. - noUncheckedIndexedAccess:
true— Addsundefinedto types accessed via index signatures. - noUnusedLocals:
true— Reports errors for unused local variables. - noUnusedParameters:
true— Reports errors for unused function parameters. - allowUnreachableCode:
false— Reports errors for unreachable code afterreturn,throw,break, orcontinue. - allowUnusedLabels:
false— Reports errors for unused labels in the code.
- exactOptionalPropertyTypes:
Modules
- module:
es2022— Specifies the module code generation format. - moduleDetection:
force— Forces all files to be treated as ES modules. - resolveJsonModule:
true— Allows importing.jsonfiles as typed modules. - types:
[]— Disables auto-inclusion of@types/*packages; extending configs provide their own.
- module:
Emit
- noEmitOnError:
true— Prevents emitting output files when type errors are present.
- noEmitOnError:
Interop Constraints
- verbatimModuleSyntax:
true— Preserves import and export syntax exactly as written. - isolatedModules:
true— Ensures each file can be safely transpiled in isolation. - erasableSyntaxOnly:
true— Restricts usage to syntax that can be fully erased during compilation (no enums, namespaces, or parameter properties).
- verbatimModuleSyntax:
Language and Environment
Completeness
- skipLibCheck:
true— Skips type checking of declaration files for faster builds.
- skipLibCheck:
Library development configuration
Extends the base configuration with emit settings for .d.ts generation and incremental builds.
Emit
- declaration:
true— Emits.d.tstype declaration files alongside JavaScript output. - declarationMap:
true— Generates source maps for.d.tsfiles, enabling "Go to Definition" to navigate to the original source. - sourceMap:
true— Generates.js.mapsource map files for debugging.
- declaration:
Modules
- types:
[]— Explicitly blocks ambient@types/*auto-discovery.
- types:
Interop Constraints
- isolatedDeclarations:
true— Requires explicit type annotations on exports so declaration files can be generated by tools other thantsc.
- isolatedDeclarations:
Projects
- composite:
true— Enables project references and incremental compilation.
- composite:
Library production configuration
Extends the library development configuration and strips debug artifacts for smaller, cleaner output.
Emit
- sourceMap:
false— Disables.js.mapsource map generation. - declarationMap:
false— Disables.d.ts.mapsource map generation. - removeComments:
true— Strips comments from emitted JavaScript. - stripInternal:
true— Removes declarations marked with@internalJSDoc tags from.d.tsoutput.
- sourceMap:
React JSX application configuration
Extends the base configuration for React applications with DOM types and no-emit mode.
Modules
- module:
esnext— Uses the latest module features for bundler consumption. - allowImportingTsExtensions:
true— Allows importing TypeScript files with explicit.ts/.tsxextensions. - types:
[]— Explicitly blocks ambient@types/*auto-discovery.
- module:
Emit
- noEmit:
true— Disables emitting compiled JavaScript files (bundler handles output).
- noEmit:
Language and Environment
Vite + React JSX application configuration
Extends the React JSX application configuration with Vite-specific type declarations.
Modules
- types:
["vite/client"]— Includes Vite client types (import.meta.env,import.meta.hot, asset imports). Restricts auto-included global types to onlyvite/client.
- types:
Node configuration
Extends the base configuration for Node.js tooling files (Vite configs, build scripts, etc.) processed by bundlers.
Modules
- module:
esnext— Uses the latest module features for bundler consumption. - allowImportingTsExtensions:
true— Allows importing TypeScript files with explicit.tsextensions. - types:
["node"]— Includes type declarations for Node.js globals and built-in modules.
- module:
Emit
- noEmit:
true— Disables emitting compiled JavaScript files (bundler handles output).
- noEmit:
