@canonical/typescript-config-react

中文文档
0.45.0发布于 2026/10/23LGPL-3.0构建来源已验证近 30 天下载 8806

Canonical's standard TypeScript configuration for React projects

原始使用文档
文档目录3 节
  1. Getting Started
  2. Configuration
  3. History

Canonical React Typescript Configuration

This package provides a central configuration for Canonical's React Typescript projects.

This configuration extends a base configuration, which provides more general TypeScript settings and is suitable for non-React projects.

Getting Started

  1. Install Typescript: bun add -d typescript
  2. Install this configuration: bun add -d @canonical/typescript-config-react
  3. Create a tsconfig.json file in the root of your project and extend this configuration.
{
  "extends": "@canonical/typescript-config-react"
}

Configuration

This configuration enables the following behavior:

  1. DOM library inclusion: Includes the DOM library, providing types for the DOM and browser APIs.
  2. react-jsx transform: Emits .jsx as .js with the new React JSX transform, optimized for production usage.

History

This configuration is rooted in the Canonical React Components Typescript config. It has been generalized to support non-React projects and be more minimal.

React-specific changes to the original config are listed below. For non-React relevant changes, see the base configuration README.

  • "jsx": "react" → "jsx": "react-jsx": Transforms JSX to JS with modern React JSX optimizations, instead of with React.createElement. Enables usage of JSX without importing React.

版本与发布记录

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

版本发布日期距今
0.45.0latest2026/10/2317 天前
0.44.12026/10/081 个月前
0.44.02026/10/051 个月前
0.43.02026/10/011 个月前
0.42.02026/09/281 个月前
0.40.02026/09/211 个月前

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

@canonical/typescript-config-react 是什么?

Canonical's standard TypeScript configuration for React projects

如何安装 @canonical/typescript-config-react?

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

@canonical/typescript-config-react 支持 TypeScript 吗?

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

@canonical/typescript-config-react 可以商用吗?

@canonical/typescript-config-react 使用 LGPL-3.0 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@canonical/typescript-config-react 还在维护吗?

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