{ // tsconfig.base.json,用于被 tesconfig.json 和 tesconfig.build.json 继承 "compilerOptions": { // 输出模块语法,使用版本号最新的那个,而不是实验性语法 ESNext "module": "es2022", // 模块解析策略,模拟 Vite / Rollup / webpack,支持 exports / imports,不强制 Node ESM 的严格规则 "moduleResolution": "bundler", // 显式声明使用的类型包 "types": ["node", "react", "vite/client"], // 开启所有严格类型检查,防止 any / 隐式 any 扩散 "strict": true, // 允许 ESM 导入 CJS "esModuleInterop": true, // 跳过 node_modules 类型检查,加快构建,避免第三方类型污染 "skipLibCheck": true, // 模块检测策略,不会影响 node_modules 中的第三方 CommonJS 依赖,Vite 会在预构建阶段自动将其转换为 ESM。 "moduleDetection": "force", // 保留源码中的 import / export 语句原样输出,不进行自动转换(如 import → require),通常与 moduleDetection: "force" 搭配使用 "verbatimModuleSyntax": true, // 是否检查“未使用的局部变量” "noUnusedLocals": true, // 是否检查“未使用的函数参数” "noUnusedParameters": true, // 是否只允许“可擦除的语法(Erasable Syntax),确保 TypeScript 语法在编译后可完全移除 "erasableSyntaxOnly": true, // 是否禁止 switch 语句中的 case 贯穿(fallthrough),如果 case 没有 break / return,会报错 "noFallthroughCasesInSwitch": true } }