https://github.com/zanminkian/tsconfig
Strict shared tsconfig out-of-box
https://github.com/zanminkian/tsconfig
nestjs out-of-box strict tsconfig typescript
Last synced: 10 months ago
JSON representation
Strict shared tsconfig out-of-box
- Host: GitHub
- URL: https://github.com/zanminkian/tsconfig
- Owner: zanminkian
- License: mit
- Created: 2022-12-09T12:06:48.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-17T18:22:00.000Z (over 2 years ago)
- Last Synced: 2025-03-04T06:46:58.596Z (11 months ago)
- Topics: nestjs, out-of-box, strict, tsconfig, typescript
- Language: TypeScript
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @zanminkian/tsconfig
Strict shared tsconfig out-of-box
[](https://github.com/zanminkian/tsconfig/blob/main/LICENSE)
[](https://www.npmjs.com/package/@zanminkian/tsconfig)
[](https://www.npmjs.com/package/@zanminkian/tsconfig)
[](https://www.npmjs.com/package/@zanminkian/tsconfig)
[](https://packagephobia.com/result?p=@zanminkian/tsconfig)
## Feature
- Strictest configs with best practices.
- One-line of tsconfig.
- Support `ESM` and `CommonJS` by `type` field in `package.json`.
- Support FE (eg: [React](https://github.com/facebook/react)) & BE (eg: [Nest](https://github.com/nestjs/nest)) project.
## Requirement
- Typescript 5.0+.
- Node 16+.
## Usage
### Install
```sh
npm i @zanminkian/tsconfig -D
```
For node project, you may need to install `@types/node` additionally.
```sh
npm i @types/node -D
```
For frontend project (like React), you may need to install `@types/web` additionally.
```sh
npm i @types/web -D
```
### Config `tsconfig.json`
```json
{
"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
```json
{
"extends": "@zanminkian/tsconfig"
}
```
#### tsconfig.build.json
```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
```json
{
"extends": "@zanminkian/tsconfig"
}
```
#### tsconfig.build.json in each app
```json
{
"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:
```txt
Usage: tsconfig init [options]
init a tsconfig file
Options:
-t, --to directory that generating to (default: ".")
-n, --name tsconfig file name (default: "tsconfig.json")
-h, --help display help for command
```
## License
MIT