@zanminkian/tsconfig
Strict shared tsconfig out-of-box
Feature
- Strictest configs with best practices.
- One-line of tsconfig.
- Support
ESM
andCommonJS
bytype
field inpackage.json
. - Support FE (eg: React) & BE (eg: Nest) project.
Requirement
- Typescript 5.0+.
- Node 16+.
Usage
Install
npm i @zanminkian/tsconfig -D
For node project, you may need to install @types/node
additionally.
npm i @types/node -D
For frontend project (like React), you may need to install @types/web
additionally.
npm i @types/web -D
tsconfig.json
Config {
"extends": "@zanminkian/tsconfig"
}
Best Practices
Here are the best practices if you are using this package.
For polyrepo
├── src
│ └── index.ts
├── test
│ └── index.spec.ts
├── package.json
├── tsconfig.build.json
└── tsconfig.json
tsconfig.json
{
"extends": "@zanminkian/tsconfig"
}
tsconfig.build.json
{
"extends": "./tsconfig",
"include": ["src"],
"exclude": ["**/*.spec.ts"],
"compilerOptions": {
"outDir": "dist"
}
}
For monorepo
├── apps
│ ├── app1
│ │ ├── src
│ │ │ └── main.ts
│ │ ├── test
│ │ │ └── main.spec.ts
│ │ ├── package.json
│ │ └── tsconfig.build.json
│ └── app2
│ ├── src
│ │ └── main.ts
│ ├── test
│ │ └── main.spec.ts
│ ├── package.json
│ └── tsconfig.build.json
├── package.json
└── tsconfig.json
tsconfig.json in the root of project
{
"extends": "@zanminkian/tsconfig"
}
tsconfig.build.json in each app
{
"extends": "../../tsconfig",
"include": ["src"],
"exclude": ["**/*.spec.ts"],
"compilerOptions": {
"outDir": "dist"
}
}
Commands
After installing @zanminkian/tsconfig
, you can run npx tsconfig init
command to generate a tsconfig.json
file. Run npx tsconfig init -h
for more detail of the command:
Usage: tsconfig init [options]
init a tsconfig file
Options:
-t, --to <path> directory that generating to (default: ".")
-n, --name <filename> tsconfig file name (default: "tsconfig.json")
-h, --help display help for command
License
MIT