feat: tsconfig 添加注释
This commit is contained in:
@@ -1,24 +1,60 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// 指定编译后的目标语言版本为 ECMAScript 2020
|
||||
"target": "ES2020",
|
||||
// 允许 TypeScript 类定义字段时使用 `defineProperty`,用于增强类字段的行为
|
||||
"useDefineForClassFields": true,
|
||||
// 输出模块的格式为最新的 ECMAScript 模块标准
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
// 指定要包含的库文件,包含 ECMAScript 2020、DOM 和可迭代的 DOM 对象
|
||||
"lib": [
|
||||
"ES2020",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
],
|
||||
// 跳过库文件的类型检查以加快编译速度
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
// 使用打包工具的模块解析模式,如 Vite 和 Webpack
|
||||
"moduleResolution": "bundler",
|
||||
// 允许直接导入 TypeScript 文件时带上文件扩展名
|
||||
"allowImportingTsExtensions": true,
|
||||
// 强制每个文件都是一个独立的模块,用于与 Babel 等工具一起工作
|
||||
"isolatedModules": true,
|
||||
// 强制启用模块检测,确保 TypeScript 在模块层面检查代码
|
||||
"moduleDetection": "force",
|
||||
// 禁止生成输出文件,通常在 Vite 等打包工具中使用,因为打包工具负责生成输出
|
||||
"noEmit": true,
|
||||
// 保留 JSX 语法,通常用于 React 项目,后续由 Babel 或其他工具处理
|
||||
"jsx": "preserve",
|
||||
|
||||
/* Linting */
|
||||
// 启用严格模式,增强 TypeScript 的类型检查
|
||||
"strict": true,
|
||||
// 禁止存在未使用的局部变量
|
||||
"noUnusedLocals": true,
|
||||
// 禁止存在未使用的函数参数
|
||||
"noUnusedParameters": true,
|
||||
// 确保在 `switch` 语句中,所有的 `case` 都必须有 `break` 或返回值,防止意外的代码运行
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
|
||||
// 包含项目中所有 TypeScript、TSX 和 Vue 文件
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.vue"
|
||||
]
|
||||
}
|
||||
// • target: 指定编译后的 ECMAScript 版本。较新的版本支持更现代的 JavaScript 语法和特性。
|
||||
// • lib: 定义编译时包含的库文件,决定代码中可以使用的 API(如 DOM 或 ES2020 标准库)。
|
||||
// • module: 指定输出的模块格式,这通常决定了生成的代码如何在其他模块系统中使用。
|
||||
// • skipLibCheck: 如果设置为 true,TypeScript 编译器会跳过库文件的类型检查,缩短编译时间。
|
||||
// • moduleResolution: 定义模块的解析策略。bundler 模式为现代打包工具设计,如 Vite 或 Webpack。
|
||||
// • allowImportingTsExtensions: 允许导入 TypeScript 文件时带有扩展名 .ts。
|
||||
// • isolatedModules: 每个文件独立编译为一个模块,适用于与 Babel 一起使用时确保每个文件可以独立处理。
|
||||
// • moduleDetection: 强制模块检测策略,避免 TypeScript 在模块边界上忽略某些检查。
|
||||
// • noEmit: 禁止编译器生成输出文件,适用于打包工具处理输出时。
|
||||
// • jsx: 控制 JSX 语法的处理方式,preserve 表示不转换 JSX 语法,适用于 React 项目。
|
||||
// • strict: 启用严格的类型检查规则。
|
||||
// • noUnusedLocals: 禁止在代码中存在未使用的局部变量。
|
||||
// • noUnusedParameters: 禁止函数中存在未使用的参数。
|
||||
// • noFallthroughCasesInSwitch: 防止 switch 语句中 case 语句意外地执行下一个 case。
|
||||
@@ -1,22 +1,52 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// 指定编译后的目标语言版本为 ECMAScript 2022
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
// 指定要包含的库文件,这里包含了 ECMAScript 2023 的标准库
|
||||
"lib": [
|
||||
"ES2023"
|
||||
],
|
||||
// 输出模块的格式为最新的 ECMAScript 模块标准
|
||||
"module": "ESNext",
|
||||
// 跳过库文件的类型检查以加快编译速度
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
// 使用打包工具的模块解析模式,如 Vite 和 Webpack
|
||||
"moduleResolution": "bundler",
|
||||
// 允许直接导入 TypeScript 文件时带上文件扩展名
|
||||
"allowImportingTsExtensions": true,
|
||||
// 强制每个文件都是一个独立的模块,用于与 Babel 等工具一起工作
|
||||
"isolatedModules": true,
|
||||
// 强制启用模块检测,确保 TypeScript 在模块层面检查代码
|
||||
"moduleDetection": "force",
|
||||
// 禁止生成输出文件,通常在 Vite 等打包工具中使用,因为打包工具负责生成输出
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
// 启用严格模式,增强 TypeScript 的类型检查
|
||||
"strict": true,
|
||||
// 禁止存在未使用的局部变量
|
||||
"noUnusedLocals": true,
|
||||
// 禁止存在未使用的函数参数
|
||||
"noUnusedParameters": true,
|
||||
// 确保在 `switch` 语句中,所有的 `case` 都必须有 `break` 或返回值,防止意外的代码运行
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
// 仅包括 `vite.config.ts` 文件作为 TypeScript 编译目标
|
||||
"include": [
|
||||
"vite.config.ts"
|
||||
]
|
||||
}
|
||||
// • target: 指定编译后的 ECMAScript 版本。较新的版本支持更现代的 JavaScript 语法和特性。
|
||||
// • lib: 定义编译时包含的库文件,决定代码中可以使用的 API(如 DOM 或 ES2020 标准库)。
|
||||
// • module: 指定输出的模块格式,这通常决定了生成的代码如何在其他模块系统中使用。
|
||||
// • skipLibCheck: 如果设置为 true,TypeScript 编译器会跳过库文件的类型检查,缩短编译时间。
|
||||
// • moduleResolution: 定义模块的解析策略。bundler 模式为现代打包工具设计,如 Vite 或 Webpack。
|
||||
// • allowImportingTsExtensions: 允许导入 TypeScript 文件时带有扩展名 .ts。
|
||||
// • isolatedModules: 每个文件独立编译为一个模块,适用于与 Babel 一起使用时确保每个文件可以独立处理。
|
||||
// • moduleDetection: 强制模块检测策略,避免 TypeScript 在模块边界上忽略某些检查。
|
||||
// • noEmit: 禁止编译器生成输出文件,适用于打包工具处理输出时。
|
||||
// • jsx: 控制 JSX 语法的处理方式,preserve 表示不转换 JSX 语法,适用于 React 项目。
|
||||
// • strict: 启用严格的类型检查规则。
|
||||
// • noUnusedLocals: 禁止在代码中存在未使用的局部变量。
|
||||
// • noUnusedParameters: 禁止函数中存在未使用的参数。
|
||||
// • noFallthroughCasesInSwitch: 防止 switch 语句中 case 语句意外地执行下一个 case。
|
||||
Reference in New Issue
Block a user