npm.io
0.11.3 • Published 8h agoCLI

@fenge/tsconfig

Licence
MIT
Version
0.11.3
Deps
5
Size
12 kB
Vulns
0
Weekly
0
Stars
41

@fenge/tsconfig

A strict sharable tsconfig preset.

PRs Welcome

Feature

  • The best practice about tsconfig.json.
  • Strictest.
  • One-line of tsconfig.
  • Support ESM and CommonJS.
  • Support FE (eg: React) & BE (eg: Nest) project.

Usage

Install
npm i @fenge/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
Config tsconfig.json
{
  "extends": "@fenge/tsconfig"
}

Best Practices

Here are the best practices if you are using this package.

For polyrepo
├── src
│   └── index.ts
├── test
│   └── index.test.ts
├── package.json
├── tsconfig.build.json
└── tsconfig.json
tsconfig.json
{
  // If the project is for web, you may need to change `@fenge/tsconfig/node` to `@fenge/tsconfig/web`.
  "extends": ["@fenge/tsconfig", "@fenge/tsconfig/node"]
}
tsconfig.build.json
{
  "extends": ["./tsconfig.json"],
  "include": ["src"],
  "exclude": ["**/*.test.ts"]
}
For monorepo
├── packages
│   ├── pkg1
│   │   ├── src
│   │   │   └── index.ts
│   │   ├── test
│   │   │   └── index.test.ts
│   │   ├── package.json
│   │   ├── tsconfig.build.json
│   │   └── tsconfig.json
│   └── pkg2
│       ├── src
│       │   └── index.ts
│       ├── test
│       │   └── index.test.ts
│       ├── package.json
│       ├── tsconfig.build.json
│       └── tsconfig.json
└── package.json
tsconfig.json in each package
{
  // If the package is for web, you may need to change `@fenge/tsconfig/node` to `@fenge/tsconfig/web`.
  "extends": ["@fenge/tsconfig", "@fenge/tsconfig/node"]
}
tsconfig.build.json in each package
{
  "extends": ["./tsconfig.json"],
  "include": ["src"],
  "exclude": ["**/*.test.ts"]
}

Commands

After installing @fenge/tsconfig, you can run npx tsconfig init command to generate a tsconfig.json file. Run npx tsconfig -h for all commands details:

Usage: tsconfig [options] [command]

Options:
  -h, --help      display help for command

Commands:
  init [options]  init a tsconfig file
  diff [options]  show differences between recommended tsconfig and current project tsconfig
  help [command]  display help for command

License

MIT

Keywords