@checkdigit/typescript-config

中文文档
10.2.2发布于 2026/09/17MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 8990

Check Digit standard Typescript configuration

原始使用文档
文档目录10 节
  1. Introduction
  2. TypeScript Configuration
  3. Builder
  4. Options
  5. Examples
  6. Tests
  7. A note about versioning
  8. Installation
  9. Example tsconfig.json
  10. License

checkdigit/typescript-config

MIT License

Copyright © 2021–2026 Check Digit, LLC

Introduction

This module contains the standard Check Digit TypeScript configuration, along with our standard build tool builder.

TypeScript Configuration

  • currently supports Node 24.18.0 up to, but not including, Node 25, or Node 26 and above.
  • Node 25 is intentionally not part of the support contract.
  • emits esnext, with the default libraries, to avoid down-leveling. It is intended that application spec tests pick up any issues with using newer features unavailable in a particular environment. Browsers and Node.js are fast-moving targets, and can add language features at any time.
  • uses the module type of esnext.
  • all compiler options set for maximum strictness.

Builder

builder is a command line tool that generates ESM modules from the TypeScript source. It is intended to be used when publishing a package to NPM, or to bundle a package for deployment. It uses tsc for generating types, and esbuild for generating code.

Note: the require function will be defined as a global variable, to allow dynamic requires by CommonJS submodules. This is not a problem for Node.js, but will cause issues in a browser environment.

Options

  • --type the type of output to generate. Defaults to module (ESM). Valid values are module or types.
  • --entryPoint the entry point for the bundle, relative to the inDir. if not provided, the files in the inDir will be processed as individual unbundled files.
  • --inDir the input source code directory.
  • --outDir the output directory.
  • --outFile the output file, relative to --outDir. This is provided for single-file bundles, along with --entryPoint.
  • --external external modules to exclude from the bundle. Built-in node modules are automatically excluded. A wildcard * can be used to exclude multiple external modules.
  • --minify whether to minify the output.
  • --sourceMap whether to include inline sourcemap.

Examples

# build ESM .mjs files from TypeScript source
npx builder --type=module --outDir=build-esm

# build single-file ESM .mjs bundle from TypeScript source
npx builder --type=module --outDir=build-esm-bundle --entryPoint=index.ts --outFile=index.mjs

Tests

This module includes a number of integration-style tests, to ensure that a specific version of TypeScript will interoperate with builder, in addition to runtimes, libraries and frameworks used by Check Digit:

  • Recent TC39 proposals
  • Node versions supported by AWS Lambda, Google Cloud Functions, and Azure Functions
  • ESLint and @typescript-eslint/eslint-plugin
  • Built-in node:test runner
  • prettier
  • tsc, and specific features introduced in each version of TypeScript
  • esbuild
  • Wallaby.js (supports node:test by relying on native Node type-stripping support)

We do this to ensure that TypeScript upgrades do not break these dependencies, and that updates to these related projects do not break builds.

Note: New major versions of TypeScript are not immediately supported by projects such as eslint, prettier, typescript-eslint, etc. Our policy is to wait until these projects fully support the new version of TypeScript, and/or without emitting warnings during these tests, before publishing.

A note about versioning

Strict semver is a little complicated, as TypeScript itself does not adhere to semver. So our "best effort" policy is:

  • Each update to the minimum Node target (e.g., Node 18 to Node 20), or a change to a major compiler output option (e.g. module, target or moduleResolution) will result in a new major version of this module. We coordinate this with whatever the latest LTS version of Node is currently supported by Amazon Lambda, Google Cloud Functions, and Azure Functions.
  • Each new "major" version of TypeScript (e.g. 5.7.x to 5.8.x) will result in a new minor version of this module.
  • A new minor update of TypeScript (e.g. 5.7.2 to 5.7.3) or a key dependency (e.g., Node 22.11 to Node 22.14) may result in a patch.

Bear in mind, any update of TypeScript can potentially break your build. But hopefully in a way that's useful.

Installation

npm add -D @checkdigit/typescript-config

Note: you do not need to explicitly install TypeScript itself, as the most recent supported version comes in as a peer dependency of @checkdigit/typescript-config.

Make sure your project's tsconfig.json extends @checkdigit/typescript-config.

Example tsconfig.json

{
  "extends": "@checkdigit/typescript-config"
}

Note this configuration has moduleResolution set to bundler. This requires the use of the builder command to produce working code for deployment.

License

MIT

版本与发布记录

@checkdigit/typescript-config 共发布 323 个版本,首次发布于 2020/09/22;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
10.2.2latest2026/09/171 个月前
10.2.2-PR.100-0799beta2026/09/171 个月前
10.2.2-PR.100-8ccc2026/09/161 个月前
10.2.12026/08/122 个月前
10.2.1-PR.98-cd732026/08/122 个月前
10.2.02026/07/293 个月前

关于 @checkdigit/typescript-config 的常见问题

@checkdigit/typescript-config 是什么?

Check Digit standard Typescript configuration

如何安装 @checkdigit/typescript-config?

在项目目录运行 npm install @checkdigit/typescript-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:esbuild(0.28.2)、typescript(>=6.0.3 <7)、@types/node(>=24)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 builder,可以用 npx builder 直接运行。

@checkdigit/typescript-config 支持 TypeScript 吗?

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

@checkdigit/typescript-config 支持 ESM 还是 CommonJS?

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

@checkdigit/typescript-config 需要什么版本的 Node.js?

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

@checkdigit/typescript-config 可以商用吗?

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

@checkdigit/typescript-config 的下载量有多少?

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

@checkdigit/typescript-config 还在维护吗?

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