npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cat-kit/tsconfig

v1.0.0

Published

TypeScript 配置预设,提供适用于不同运行环境的 TypeScript 配置

Downloads

115

Readme

@cat-kit/tsconfig

Cat-Kit 项目的 TypeScript 配置预设,提供适用于不同运行环境的 TypeScript 配置。

概述

本包提供了多个 TypeScript 配置预设,适用于不同的运行环境和项目类型:

  • 基础配置 (tsconfig.json) - 通用的严格类型检查配置
  • Bun 配置 (tsconfig.bun.json) - 适用于 Bun 运行时
  • Node.js 配置 (tsconfig.node.json) - 适用于 Node.js 环境
  • Web 配置 (tsconfig.web.json) - 适用于浏览器环境
  • Vue 配置 (tsconfig.vue.json) - 适用于 Vue 3 项目

安装

bun add -d @cat-kit/tsconfig typescript

使用方法

基础配置

适用于大多数 TypeScript 项目:

{
  "extends": "@cat-kit/tsconfig/tsconfig.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"]
}

Bun 运行时

适用于使用 Bun 运行时的项目:

{
  "extends": "@cat-kit/tsconfig/tsconfig.bun.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"]
}

Node.js 环境

适用于 Node.js 项目:

{
  "extends": "@cat-kit/tsconfig/tsconfig.node.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"]
}

浏览器环境

适用于浏览器端项目:

{
  "extends": "@cat-kit/tsconfig/tsconfig.web.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"]
}

Vue 3 项目

适用于 Vue 3 项目(需要配合 Vite):

{
  "extends": "@cat-kit/tsconfig/tsconfig.vue.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
}

配置特点

严格类型检查

  • strictNullChecks - null/undefined 作为独立类型
  • strictFunctionTypes - 函数类型严格协变/逆变
  • strictBindCallApply - bind/call/apply 参数严格匹配
  • noImplicitThis - 禁止隐式 this
  • noImplicitOverride - 类方法重写必须使用 override
  • noUncheckedIndexedAccess - 索引访问自动加上 undefined
  • useUnknownInCatchVariables - catch 变量类型为 unknown

代码质量

  • noUnusedLocals - 检测未使用的局部变量
  • allowUnreachableCode: false - 禁止不可达代码
  • forceConsistentCasingInFileNames - 强制文件名大小写一致

模块系统

  • module: "ESNext" - 使用最新的 ES 模块
  • moduleResolution: "bundler" - 使用 bundler 解析策略
  • verbatimModuleSyntax - 保持 import/export 原样输出
  • esModuleInterop - 支持 CommonJS 默认导入
  • allowSyntheticDefaultImports - 允许合成默认导入

性能优化

  • skipLibCheck - 跳过 node_modules 类型检查

配置说明

tsconfig.json(基础配置)

通用的严格 TypeScript 配置,包含所有类型检查和代码质量选项。不包含特定运行时的类型定义。

tsconfig.bun.json

继承基础配置,添加:

  • lib: ["ESNext"] - 仅包含 ESNext 库
  • types: ["bun"] - 包含 Bun 类型定义

tsconfig.node.json

继承基础配置,添加:

  • lib: ["ESNext"] - 仅包含 ESNext 库
  • types: ["node"] - 包含 Node.js 类型定义

tsconfig.web.json

继承基础配置,添加:

  • lib: ["ESNext", "DOM", "DOM.Iterable"] - 包含 DOM API
  • types: [] - 不包含额外的全局类型

tsconfig.vue.json

继承基础配置,添加:

  • jsx: "preserve" - 保留 JSX,由 Vue 插件处理
  • jsxImportSource: "vue" - 使用 Vue 3 JSX 工厂
  • types: [] - 类型定义由 Vite 插件注入

注意事项

  1. TypeScript 版本:需要 TypeScript >= 5.5.0
  2. 类型定义:根据使用的运行时环境,需要安装对应的类型定义包:
    • Bun: @types/bun
    • Node.js: @types/node
  3. Vue 项目:使用 Vue 配置时,需要配合 Vite 和 Vue 插件使用
  4. 编辑器支持:建议在编辑器中启用 JSON with Comments 支持,以获得更好的配置提示

许可证

MIT