109 lines
2.5 KiB
JSON
109 lines
2.5 KiB
JSON
{
|
||
// 此文件仅用于类型检查,不用于类型检查,构建时会指定使用 tsconfig.build.json
|
||
"extends": "./tsconfig.base.json",
|
||
"compilerOptions": {
|
||
// Browser api,需要加 "DOM","DOM.Iterable"
|
||
// Node api,需要加 "ES2025",始终使用带版本号的最新版本
|
||
// NextJs api,属于同构,server 端会预处理 DOM,计算url,三个都需要 "ES2025", "DOM", "DOM.Iterable"
|
||
"lib": ["ES2025", "DOM", "DOM.Iterable"],
|
||
|
||
/**
|
||
* 显式声明使用的类型包
|
||
* - node:Node.js API
|
||
* - react:JSX / React 类型
|
||
* - vite/client:import.meta / env
|
||
*/
|
||
"types": ["node", "react", "react-dom"],
|
||
|
||
/**
|
||
* React JSX 编译模式
|
||
* - 使用 React 17+ 新 JSX Transform
|
||
* - 不需要手动 import React
|
||
*/
|
||
"jsx": "react-jsx",
|
||
|
||
/**
|
||
* 编译输出目录
|
||
* - tsc / tsc -b 都会用到
|
||
*/
|
||
"outDir": "./dist",
|
||
|
||
/**
|
||
* 源码根目录
|
||
* - 确保 dist 结构与 src 一致
|
||
* - 对 declaration 路径至关重要
|
||
*/
|
||
"rootDir": "./src",
|
||
|
||
/**
|
||
* 生成 .d.ts 类型声明文件
|
||
* - 组件库 / npm 包发布必需
|
||
* - 对应用项目无害,仅影响类型输出
|
||
*/
|
||
"declaration": true,
|
||
|
||
/**
|
||
* 强制单文件可独立编译
|
||
* - 适配 esbuild / SWC / bundler 编译模型
|
||
* - 禁止依赖跨文件类型推断(enum / namespace 等)
|
||
*/
|
||
"isolatedModules": true
|
||
},
|
||
/**
|
||
* 参与类型检查和编译的文件
|
||
* - 只扫描 src
|
||
* - 其它目录通过 exclude 排除
|
||
*/
|
||
"include": ["src"],
|
||
|
||
/**
|
||
* 明确排除非源码内容
|
||
* - 避免污染类型系统
|
||
* - 防止误入 dist / test / config
|
||
* - 保证发布包干净
|
||
*/
|
||
"exclude": [
|
||
"node_modules",
|
||
"dist",
|
||
|
||
// ---------- build / cache ----------
|
||
".turbo/**/*",
|
||
".cache/**/*",
|
||
".vite/**/*",
|
||
|
||
// ---------- 配置文件 ----------
|
||
"vite.config.ts",
|
||
"*.config.ts",
|
||
"*.config.js",
|
||
"tsconfig.*.json",
|
||
|
||
// ---------- 测试相关 ----------
|
||
"__tests__/**/*",
|
||
"test/**/*",
|
||
"tests/**/*",
|
||
"**/*.test.ts",
|
||
"**/*.test.tsx",
|
||
"**/*.spec.ts",
|
||
"**/*.spec.tsx",
|
||
|
||
// ---------- Storybook ----------
|
||
".storybook/**/*",
|
||
"stories/**/*",
|
||
|
||
// ---------- 示例 / 脚本 ----------
|
||
"example/**/*",
|
||
"examples/**/*",
|
||
"scripts/**/*",
|
||
|
||
// ---------- 环境与静态资源 ----------
|
||
".env",
|
||
".env.*",
|
||
"public/**/*",
|
||
|
||
// ---------- 文档 ----------
|
||
"docs/**/*",
|
||
"README.md",
|
||
"LICENSE"
|
||
]
|
||
}
|