Skip to content

tsconfig.json

json
{
  "compilerOptions": {
    // 目标 JavaScript 版本
    "target": "ESNext",
    // 模块系统
    "module": "ESNext",
    // 模块解析策略
    "moduleResolution": "bundler",
    // 允许默认导入
    "allowSyntheticDefaultImports": true,
    // 从 tslib 导入辅助工具函数
    "importHelpers": true,
    // 生成相应的 .d.ts 文件
    "declaration": true,
    // 生成 sourceMap
    "sourceMap": true,
    // 严格模式
    "strict": true,
    // 不允许隐式的 any 类型
    "noImplicitAny": false,
    // 不允许 null/undefined 上的属性访问
    "strictNullChecks": false,
    // 不允许 this 有隐式的 any 类型
    "noImplicitThis": false,
    // 检查 switch 语句的完整性
    "noFallthroughCasesInSwitch": true,
    // 不允许未使用的局部变量
    "noUnusedLocals": false,
    // 不允许未使用的参数
    "noUnusedParameters": false,
    // 确保函数有返回值(修正了之前的错误选项)
    "noImplicitReturns": false,
    // 跳过库检查,减少编译时间
    "skipLibCheck": true,
    // 允许编译 JS 文件
    "allowJs": true,
    // 检查 JS 文件中的类型错误
    "checkJs": false,
    // 启用装饰器
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    // 库文件
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    // Vite 类型
    "types": ["vite/client"],
    // 支持别名解析
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "vueCompilerOptions": {
    "globalTypesPath": "types/global.d.ts",
    "target": "3.5",
    "strictTemplates": true
  },
  // 需要编译的文件
  "include": ["src/**/*.ts", "src/**/*.vue", "mock/**/*.ts", "vite.config.ts", "types/**/*.d.ts"],
  // 排除的文件
  "exclude": ["node_modules", "dist"]
}