TS代码规范
361字约1分钟
2024-11-12
TS代码规范配置
{
"compilerOptions": {
"target": "ES5", // 编译后的目标版本
"module": "ESNext", // 指定模块代码生成
"moduleResolution": "Node", // 指定模块解析策略
"allowJs": true, // 允许编译js、jsx文件
"checkJs": true, // 允许在js文件中检查错误
"esModuleInterop": true, // 允许 export 导出 import 引入
"forceConsistentCasingInFileNames": true, // 禁止对同一个文件进行不同大小写的引用
"strict": true, // 启用所有严格类型检查选项
"rootDir": "./", // 指定输入文件
"outDir": "./dist", // 指定输出文件
"alwaysStrict": true, // 启用所有严格类型检查选项
"skipLibCheck": true, // 跳过库文件的类型检查
"allowSyntheticDefaultImports": true, // 允许从没有默认导出的模块中默认导入
"resolveJsonModule": true, // 允许使用json模块
"sourceMap": false, // 生成对应的sourceMap文件
"declaration": true, // 生成对应的.d.ts文件
"declarationMap": true, // 生成对应的.d.ts.map文件
"emitDeclarationOnly": true, // 只生成对应的.d.ts文件
"importHelpers": true, // 启用importHelpers
"lib": ["ESNext", "DOM", "DOM.Iterable", "ScriptHost"], // 指定要包含在编译中的库文件
"typeRoots": ["./"], // 指定类型声明文件的位置
"noUnusedLocals": true, // 检查未使用的局部变量
"removeComments": true, // 移除注释
"experimentalDecorators": true, // 启用装饰器
"emitDecoratorMetadata": true, // 启用装饰器元数据
},
"include": ["src/**/*"], // 指定要编译的文件
"exclude": ["node_modules", "dist"], // 指定要排除的文件
"path":{
"@/*": ["src/*"] // 指定路径别名
}
}