@kcconfigs/tsconfig
v0.1.0
Published
Shared tsconfig.json
Readme
@kcconfigs/tsconfig
Shared TypeScript configuration presets for the kc-workspace monorepo. Provides multiple tsconfig.json templates for different project types and use cases.
Prerequisites
- TypeScript: 5.5.0 or higher (as peer dependency)
Installation
pnpm add --save-dev typescript @kcconfigs/tsconfigRecommended settings
"type": "module"on package.json (learn more)
Usage
This package provides multiple tsconfig presets, environments, and features:
Presets
| Name | Description |
| ------------------------------ | ------------------------------------------ |
| @kcconfigs/tsconfig/base | Base configuration for general typescript |
| @kcconfigs/tsconfig | Default configuration |
| @kcconfigs/tsconfig/commonjs | Default but for CommonJS (not recommended) |
| @kcconfigs/tsconfig/root | Use monorepo root |
| @kcconfigs/tsconfig/bundler | Use for with bundler (vite, tsdown, etc.) |
| @kcconfigs/tsconfig/dts | Use for generate declaration and maps |
| @kcconfigs/tsconfig/zshy | Use with zshy |
Example use presets
{
"extends": "@kcconfigs/tsconfig"
}Environments
| Name | Description |
| ------------------------------- | ----------------------- |
| @kcconfigs/tsconfig/envs/node | For node environment |
| @kcconfigs/tsconfig/envs/web | For browser environment |
{
"extends": [
"@kcconfigs/tsconfig",
"@kcconfigs/tsconfig/envs/node"
]
}Features
| Name | Description |
| ---------------------------------------------- | --------------------------------------------------- |
| @kcconfigs/tsconfig/features/bundler | Set for bundler mode |
| @kcconfigs/tsconfig/features/declaration | Add declaration files |
| @kcconfigs/tsconfig/features/declarationOnly | Only emit declaration files |
| @kcconfigs/tsconfig/features/diagnostics | Add diagnostics output for debugging |
| @kcconfigs/tsconfig/features/nodeRuntime | Set typescript to support directly run from Node.js |
| @kcconfigs/tsconfig/features/noIncremental | Disable incremental from base config |
| @kcconfigs/tsconfig/features/noSourcemap | Disable source map and declaration maps output |
| @kcconfigs/tsconfig/features/noStrict | Disable strict mode when type checks |
| @kcconfigs/tsconfig/features/tslib | Enable using helpers from tslib |
| @kcconfigs/tsconfig/features/types | Support custom @kctypes/* packages as types |
| @kcconfigs/tsconfig/features/js | Allow JavaScript files to be imported |
| @kcconfigs/tsconfig/features/es5 | Set target to ES5 (2009) for backward compatible |
| @kcconfigs/tsconfig/features/es6 | Set target to ES6 (ES2015) for backward compatible |
| @kcconfigs/tsconfig/features/empty | Starting point for new features |
Example use features
{
"extends": [
"@kcconfigs/tsconfig",
"@kcconfigs/tsconfig/envs/node",
"@kcconfigs/tsconfig/features/noSourcemap"
]
}Custom settings
To extend configurations with custom settings:
{
"extends": ["@kcconfigs/tsconfig", "@kcconfigs/tsconfig/envs/node"],
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts"],
"compilerOptions": {
"declaration": true
}
}Compiler Options
All configurations inherit base settings:
- Target: ESNext
- Module: ESNext
- Strict Mode: Enabled
- Source Maps: Enabled
- Check Js: Enabled
Example
Below are the example configuration per tools or frameworks.
TSDown
{
"extends": "@kcconfigs/tsconfig/bundler"
}