@cprussin/tsconfig

中文文档
5.0.0发布于 2026/04/23MITES Module零依赖构建来源已验证近 30 天下载 3万

A set of strict shared typescript configs

原始使用文档
文档目录5 节
  1. base.json
  2. dom.json
  3. react.json
  4. nextjs.json
  5. webworker.json

@cprussin/tsconfig v5.0.0


@cprussin/tsconfig v5.0.0

This package contains a set of strict shared typescript configs.

Installing

Use the package manager of your choice to install:

  • npm: npm install --save-dev @cprussin/tsconfig
  • pnpm: pnpm add -D @cprussin/tsconfig
  • yarn: yarn add -D @cprussin/tsconfig

These configs do not set the types array, so ambient @types/* packages (e.g. @types/node, @types/bun, @types/jest) are not loaded by default. Add the ones you need in your own tsconfig.json, for example:

{
  "extends": "@cprussin/tsconfig/base.json",
  "compilerOptions": {
    "types": ["node"]
  }
}

Usage

Add the config you want to extend to your tsconfig.json, for example:

{
  "extends": "@cprussin/tsconfig/base.json"
}

Note that "noEmit": true is set by configs here. The intention is that most of the case, you're type checking with typescript and distributed untranspiled files, or that if you're transpiling then the transpilation tools you're using will override that setting in their own configs as needed. For instance, if you're using webpack, you could configure ts-loader like this:

{
  loader: "ts-loader",
  options: {
    compilerOptions: {
      sourceMap: process.env.NODE_ENV === "development",
      noEmit: false,
    },
  },
}

Or you could have a build script in your package.json that runs tsc directly:

{
  "name": "foo",
  "scripts": {
    "build": "tsc --noEmit false --outDir ./dist"
  }
}

Configurations

base.json

// tsconfig.json
{
  "extends": "@cprussin/tsconfig/base.json"
}

The base configuration that everything else extends from. Sets a bunch of strict options such as "strict": true, "allowJs": false, "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, etc. If you want to be as strict as I do and you aren't incrementally adding typescript to a legacy project, you probably don't want to override most of these options, but it might make sense to override the target or lib options.

Note that no options are set for JSX or for DOM libraries. If you need any of that, you'll want to use one of the configs that extends base.json instead of using it directly.

dom.json

// tsconfig.json
{
  "extends": "@cprussin/tsconfig/dom.json"
}

Extends the base.json config by adding the dom and dom.iterable libs.

react.json

// tsconfig.json
{
  "extends": "@cprussin/tsconfig/react.json"
}

Adds the "jsx": "react-jsx" option to the dom.json config.

nextjs.json

// tsconfig.json
{
  "extends": "@cprussin/tsconfig/nextjs.json"
}

Adds the nextjs typescript plugin to the react.json config, and switches jsx to preserve along with module/moduleResolution set for bundler-based workflows.

webworker.json

// tsconfig.json
{
  "extends": "@cprussin/tsconfig/webworker.json"
}

Extends the base.json config by adding the webworker lib.

版本与发布记录

@cprussin/tsconfig 共发布 14 个版本,首次发布于 2023/05/05;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.0.0latest2026/04/236 个月前
4.0.22025/12/0111 个月前
4.0.12025/06/211.4 年前
4.0.02025/06/181.4 年前
3.1.22025/04/011.6 年前
3.1.12025/03/121.7 年前

关于 @cprussin/tsconfig 的常见问题

@cprussin/tsconfig 是什么?

A set of strict shared typescript configs

如何安装 @cprussin/tsconfig?

在项目目录运行 npm install @cprussin/tsconfig,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:typescript(^6.0.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cprussin/tsconfig 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cprussin__tsconfig 是否存在。

@cprussin/tsconfig 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cprussin/tsconfig 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cprussin/tsconfig 可以商用吗?

@cprussin/tsconfig 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cprussin/tsconfig 的下载量有多少?

根据 npm 官方下载统计,@cprussin/tsconfig 在 2026/10/11 – 2026/11/09 这 30 天内被下载 30,110 次,日均约 1,004 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cprussin/tsconfig 还在维护吗?

最新版本 5.0.0 发布于 2026/04/23(6 个月前);至今共发布 14 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/05/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。