@code-pushup/typescript-plugin

中文文档
0.126.4发布于 2026/09/11MITTypeScriptES Module构建来源已验证近 30 天下载 1865

Code PushUp plugin for incrementally adopting strict compilation flags in TypeScript projects

原始使用文档
文档目录5 节
  1. Getting started
  2. About TypeScript checks
  3. Plugin architecture
  4. Plugin configuration specification
  5. Optionally set up categories

@code-pushup/typescript-plugin

npm downloads dependencies

🕵️ Code PushUp plugin for measuring TypeScript quality with compiler diagnostics. 🔥

This plugin allows you to incrementally adopt strict compilation flags in TypeScript projects. It analyzes your codebase using the TypeScript compiler to detect potential issues and configuration problems.

TypeScript compiler diagnostics are mapped to Code PushUp audits in the following way:

  • value: The number of issues found for a specific TypeScript configuration option (e.g. 3)
  • displayValue: The number of issues found (e.g. "3 issues")
  • score: Binary scoring - 1 if no issues are found, 0 if any issues exist
  • Issues are mapped to audit details, containing:
    • Source file location
    • Error message from TypeScript compiler
    • Code reference where the issue was found

Getting started

  1. If you haven't already, install @code-pushup/cli and create a configuration file.

  2. Install as a dev dependency with your package manager:

    npm install --save-dev @code-pushup/typescript-plugin
    
    yarn add --dev @code-pushup/typescript-plugin
    
    pnpm add --save-dev @code-pushup/typescript-plugin
    
  3. Add this plugin to the plugins array in your Code PushUp CLI config file (e.g. code-pushup.config.ts).

    By default, a root tsconfig.json is used to compile your codebase. Based on those compiler options, the plugin will generate audits.

    import typescriptPlugin from '@code-pushup/typescript-plugin';
    
    export default {
      // ...
      plugins: [
        // ...
        typescriptPlugin(),
      ],
    };
    
  4. Run the CLI with npx code-pushup collect and view or upload the report (refer to CLI docs).

About TypeScript checks

The TypeScript plugin analyzes your codebase using the TypeScript compiler to identify potential issues and enforce best practices. It helps ensure type safety and maintainability of your TypeScript code.

The plugin provides multiple audits grouped into different sets:

  • Semantic Errors: semantic-errors - Errors that occur during type checking and type inference
  • Syntax Errors: syntax-errors - Errors that occur during parsing and lexing of TypeScript source code
  • Configuration Errors: configuration-errors - Errors that occur when parsing TypeScript configuration files
  • Declaration and Language Service Errors: declaration-and-language-service-errors - Errors that occur during TypeScript language service operations
  • Internal Errors: internal-errors - Errors that occur during TypeScript internal operations
  • No Implicit Any Errors: no-implicit-any-errors - Errors related to noImplicitAny compiler option
  • Unknown Codes: unknown-codes - Errors that do not match any known TypeScript error code

Each audit:

  • Checks for specific TypeScript compiler errors and warnings
  • Provides a score based on the number of issues found
  • Includes detailed error messages and locations

Each set is also available as group in the plugin. See more under Audits and Groups.

Plugin architecture

Plugin configuration specification

The plugin accepts the following parameters:

OptionTypeDefaultDescription
tsconfigstring | string[]tsconfig.jsonPath(s) to your tsconfig.json file(s)
onlyAuditsstring[]undefinedAn array of audit slugs to specify which documentation types you want to measure. Only the specified audits will be included in the results

tsconfig

Optional parameter. The tsconfig option accepts a path or an array of paths to your config files. Defaults to tsconfig.json.

typescriptPlugin({
  tsconfig: './tsconfig.json',
});

You can also provide multiple tsconfigs to combine results from different configurations (e.g., separate configs for source and test files):

typescriptPlugin({
  tsconfig: ['./tsconfig.lib.json', './tsconfig.spec.json'],
});

If you're using an Nx monorepo, a helper function is provided to auto-discover tsconfigs from all projects:

import typescriptPlugin, { tsconfigFromAllNxProjects } from '@code-pushup/typescript-plugin';

export default {
  plugins: [
    await typescriptPlugin({
      tsconfig: await tsconfigFromAllNxProjects(),
    }),
  ],
};

You can exclude specific projects by name:

await tsconfigFromAllNxProjects({ exclude: ['my-app-e2e'] });

onlyAudits

The onlyAudits option allows you to specify which documentation types you want to measure. Only the specified audits will be included in the results. All audits are included by default. Example:

typescriptPlugin({
  onlyAudits: ['no-implicit-any'],
});

Optionally set up categories

Reference audits (or groups) which you wish to include in custom categories (use npx code-pushup print-config to list audits and groups).

Assign weights based on what influence each TypeScript checks should have on the overall category score (assign weight 0 to only include as extra info, without influencing category score).

// ...
categories: [
  {
    slug: 'typescript',
    title: 'TypeScript',
    refs: [
      {
        type: 'audit',
        plugin: 'typescript',
        slug: 'semantic-errors',
        weight: 2,
      },
      {
        type: 'audit',
        plugin: 'typescript',
        slug: 'syntax-errors',
        weight: 1,
      },
      // ...
    ],
  },
  // ...
];

Also groups can be used:

// ...
categories: [
  {
    slug: 'typescript',
    title: 'TypeScript',
    refs: [
      {
        slug: 'problems',
        weight: 1,
        type: 'group',
        plugin: 'typescript',
      },
      // ...
    ],
  },
  // ...
];

版本与发布记录

@code-pushup/typescript-plugin 共发布 97 个版本,首次发布于 2025/04/04;过去 12 个月发布了 62 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.126.4latest2026/09/111 个月前
0.126.32026/05/195 个月前
0.126.22026/03/317 个月前
0.126.12026/03/317 个月前
0.126.02026/03/307 个月前
0.125.02026/03/277 个月前

关于 @code-pushup/typescript-plugin 的常见问题

@code-pushup/typescript-plugin 是什么?

Code PushUp plugin for incrementally adopting strict compilation flags in TypeScript projects

如何安装 @code-pushup/typescript-plugin?

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

@code-pushup/typescript-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@code-pushup/typescript-plugin 支持 ESM 还是 CommonJS?

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

@code-pushup/typescript-plugin 可以商用吗?

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

@code-pushup/typescript-plugin 的下载量有多少?

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

@code-pushup/typescript-plugin 还在维护吗?

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