{ // 指定要从编译中排除的文件列表 "compilerOptions": { "target": "ESNext", // 编译出目标语言版本 "jsx": "preserve", "jsxImportSource": "vue", "lib": ["ESNext", "DOM", "ScriptHost"], // TS需要引用的库 "emitDecoratorMetadata": true, // 为装饰器启用对发出类型元数据的实验性支持 /* 实验选项 */ "experimentalDecorators": true, "baseUrl": "./", // 指定基目录以解析非相对模块名 "rootDir": ".", // 编译出目标语言版本 "module": "ESNext", // 生成代码的模板标准 "moduleResolution": "node", // 指定TypeScript如何从给定的模块说明符查找文件 // 指定一组条目,它们将导入重新映射到其他查找位置 "paths": { "~/*": ["./*"], "@/*": ["./src/*"] }, "resolveJsonModule": true, // 是否解析 JSON 模块 "types": ["vite/client", "node"], // 指定要包含的类型包名,而不需要在源文件中引用 // "sourceMap": true, //为发出的JavaScript文件创建源映射文件。 // "declaration": true, // 从项目中的TypeScript和JavaScript文件生成.d.ts文件 // "declarationMap": true, // 为d.ts文件创建源地图 /* 严格检查选项 */ "strict": true, // 开启所有严格的类型检查 "strictBindCallApply": true, // 检查bind、call和apply方法的参数是否与原始函数匹配。 "strictFunctionTypes": true, // 在给函数赋值时,要确保参数和返回值是子类型兼容的。 "strictNullChecks": true, // 在进行类型检查时,请考虑null和undefined。 "strictPropertyInitialization": true, // 类的实例属性必须初始化 "alwaysStrict": true, // 在代码中注入'use strict' "noFallthroughCasesInSwitch": true, // 检查switch中是否含有case没有使用break跳出 "noImplicitAny": false, // 不允许隐式的any类型 "noImplicitOverride": true, // 是否检查子类继承自基类时,其重载的函数命名与基类的函数不同步问题 "noImplicitReturns": true, // 检查函数是否不含有隐式返回值 "noImplicitThis": true, // 不允许this有隐式的any类型 "noPropertyAccessFromIndexSignature": false, // 是否通过" . “(obj.key) 语法访问字段和"索引”( obj[“key”]), 以及在类型中声明属性的方式之间的一致性 "noUncheckedIndexedAccess": true, // 是否通过索引签名来描述对象上有未知键但已知值的对象 /* 额外检查 */ "noUnusedLocals": true, // 是否检查未使用的局部变量 "noUnusedParameters": true, // 是否检查未使用的参数 "newLine": "crlf", // 设置发出文件的换行符 "noEmitOnError": true, // 有错误时不进行编译 "removeComments": true, // 删除注释 // "incremental": true // 增量编译 "allowSyntheticDefaultImports": true, "esModuleInterop": true, // 允许export=导出,由import from 导入 /* 高级选项 */ "forceConsistentCasingInFileNames": true, // 是否区分文件系统大小写规则 "isolatedModules": true, // "rootDir": "./src", // 在源文件中指定根文件夹 // "outDir": "./dist", // 为所有发出的文件指定一个输出文件夹 // "extendedDiagnostics": true, //是否查看 TS 在编译时花费的时间 "pretty": true // 在输出中启用颜色和格式,使编译器错误更容易阅读 }, "include": [ "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "vite.config.*", "typings/*.ts", "typings/*.d.ts", "./**/*.ts", "./**/**/*.ts", "./**/*.tsx", "./**/*.vue" ], // 指定要包含在编译中的文件匹配列表 "exclude": ["node_modules", "dist"] }