feat: 接入Ts配置

This commit is contained in:
zdl
2025-11-14 16:15:29 +08:00
parent e23feb3c23
commit 48fdca203c
10 changed files with 663 additions and 31 deletions

81
tsconfig.json Normal file
View File

@@ -0,0 +1,81 @@
{
"compilerOptions": {
/* */
"target": "ES2020", // 编译目标(支持现代浏览器)
"lib": ["DOM", "DOM.Iterable", "ES2020"], // 类型库
"jsx": "react-jsx", // JSX 编译模式React 17+ 新 JSX 转换)
"module": "ESNext", // 模块系统
"moduleResolution": "node", // 模块解析策略
/* - */
"strict": false, // 关闭全部严格检查(初期)
"noImplicitAny": true, // 禁止隐式 any推荐启用
"strictNullChecks": false, // 暂不启用空值检查(后续开启)
"strictFunctionTypes": false, // 暂不启用函数类型严格检查
"strictBindCallApply": false, // 暂不启用 bind/call/apply 严格检查
"strictPropertyInitialization": false, // 暂不启用属性初始化检查
"noImplicitThis": true, // 禁止隐式 this
"alwaysStrict": true, // 总是以严格模式解析
/* */
"noUnusedLocals": false, // 初期不检查未使用的局部变量
"noUnusedParameters": false, // 初期不检查未使用的参数
"noImplicitReturns": false, // 初期不强制所有路径都返回值
"noFallthroughCasesInSwitch": true, // 检查 switch 语句穿透
/* - JS/TS */
"allowJs": true, // 允许编译 JS 文件
"checkJs": false, // 不检查 JS 文件(避免大量错误)
"isolatedModules": true, // 确保每个文件都可以独立编译
"esModuleInterop": true, // ES 模块互操作性
"allowSyntheticDefaultImports": true, // 允许默认导入
"skipLibCheck": true, // 跳过库文件类型检查(加快编译)
"forceConsistentCasingInFileNames": true, // 强制文件名大小写一致
"resolveJsonModule": true, // 支持导入 JSON 文件
/* */
"noEmit": true, // 不生成输出文件(由 Babel/Webpack 处理)
"declaration": false, // 不生成类型声明文件
"sourceMap": false, // 不生成 source map由 Webpack 处理)
/* - craco.config.js */
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@assets/*": ["src/assets/*"],
"@components/*": ["src/components/*"],
"@constants/*": ["src/constants/*"],
"@contexts/*": ["src/contexts/*"],
"@data/*": ["src/data/*"],
"@hooks/*": ["src/hooks/*"],
"@layouts/*": ["src/layouts/*"],
"@lib/*": ["src/lib/*"],
"@mocks/*": ["src/mocks/*"],
"@providers/*": ["src/providers/*"],
"@routes/*": ["src/routes/*"],
"@services/*": ["src/services/*"],
"@store/*": ["src/store/*"],
"@styles/*": ["src/styles/*"],
"@theme/*": ["src/theme/*"],
"@utils/*": ["src/utils/*"],
"@variables/*": ["src/variables/*"],
"@views/*": ["src/views/*"]
}
},
/* / */
"include": [
"src/**/*", // 包含 src 目录下所有 .ts, .tsx, .js, .jsx 文件
"src/**/*.json" // 包含 JSON 文件
],
"exclude": [
"node_modules", // 排除依赖
"build", // 排除构建输出
"dist", // 排除打包输出
"scripts", // 排除脚本
"**/*.spec.ts", // 排除测试文件(可选)
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx"
]
}