mm
This commit is contained in:
@@ -1,54 +1,44 @@
|
||||
{
|
||||
// 本文件仅供 TS Server 检查语法,不负责编译,编译使用的是另一个文件 tsconfig.build.json
|
||||
|
||||
// TS 类型检查专用配置, build 配置继承后按需覆盖。
|
||||
"compilerOptions": {
|
||||
// This is a component library, so "ESNext" is a good choice. Also it requires very little down-leveling during transpilation.
|
||||
"target": "esnext",
|
||||
// Include a list of type definitions for build-in JS APIs.
|
||||
"lib": ["esnext", "DOM", "DOM.Iterable"],
|
||||
// Specify the module system for the output files. It's not required for Vite but good to have.
|
||||
// 编译后, 输出的语法格式,自从 2026 年后,cjs 模块也能识别 es 模块了,如果需要兼容老项目则调低版本
|
||||
"target": "es2023",
|
||||
// 前端用 esnext ,后端用 nodenext ,node 其实也是用 js 写的一个库,前端是不带这个库的
|
||||
"module": "esnext",
|
||||
// The types defined in "vite/client" are included in global scope.
|
||||
"types": ["node", "vite/client"],
|
||||
// Do not emit compiled output files, vite will take care of the that.
|
||||
"noEmit": true,
|
||||
// Vite will handle the resolution of the import paths.
|
||||
"moduleResolution": "bundler",
|
||||
// Use the React 17 JSX transform, importing React is no longer required.
|
||||
"jsx": "react-jsx",
|
||||
// Skip the type checking for declaration files to improve performance.
|
||||
"skipLibCheck": true,
|
||||
// Allow importing modules with ".json" extension.
|
||||
"resolveJsonModule": true,
|
||||
// "declarationMap" need to be enabled to let Vite generates source map files.
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
// Importing .js files is not allowed, enable if needed.
|
||||
"allowJs": false,
|
||||
// Fix the mis-match of behaviors between ES import and CommonJS require.
|
||||
// 所有项目必须开,兼容 es 和 cjs 导入,允许 import React from 'react' ,而非 import * as React 。
|
||||
"esModuleInterop": true,
|
||||
// Allow default import from modules with no default export, i.e. you can write `import React from 'react'` instead of `import * as React from 'react'`.
|
||||
"allowSyntheticDefaultImports": true,
|
||||
// Enforce the file name casing to be consistent with development environment.
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
// Ensure the run-time code does not depend on the TypeScript-only features, such as constant enum.
|
||||
"isolatedModules": true,
|
||||
// Allow importing TypeScript modules.
|
||||
// 允许导入 ts,tsx 扩展名,include 里可以省略后缀。
|
||||
"allowImportingTsExtensions": true,
|
||||
// Enfore "type" modifier for type imports.
|
||||
"verbatimModuleSyntax": true,
|
||||
// Ensure the public class field initialization is transpiled correctly to match the future JS standard.
|
||||
"useDefineForClassFields": true,
|
||||
// Type-checking options
|
||||
// 允许 js,jsx 扩展名,include 里可以省略后缀。
|
||||
"allowJs": true,
|
||||
// 启用装饰器,也就是 @XXX 注解。
|
||||
"experimentalDecorators": true,
|
||||
// 发射装饰器元数据。
|
||||
"emitDecoratorMetadata": true,
|
||||
// 转换 jsx 时,使用 17+ 的新语法导入 react 。
|
||||
"jsx": "react-jsx",
|
||||
// 可作为子项目,被其他项目引用,但建议使用 workspace dep 模式,不是写 references 。
|
||||
"composite": false,
|
||||
// 只加载指定类型的声明包,避免加载无用类型,提升编译速度
|
||||
"types": ["node", "vite/client"],
|
||||
// 不输出编译后的文件,也就是 dist 目录下为空, 本文件只做类型检查。
|
||||
"noEmit": true,
|
||||
// 开启严格类型检查模式,只需开启这一个,其他的等于都开启了,要注意这只是类型检查,而非语法检查。
|
||||
"strict": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": true
|
||||
// 让 TS 编译器保留用于注解的 import 语句,不要优化掉,后面 babel 转义器要用。
|
||||
"verbatimModuleSyntax": true,
|
||||
// 跳过第三方库的类型检查,加快编译速度,减少30% 。
|
||||
"skipLibCheck": true,
|
||||
// 跳过内置库的类型检查,加快编译速度,分钟级降至秒级。
|
||||
"skipDefaultLibCheck": true,
|
||||
// 增量编译,加快编译速度,尤其是大项目。
|
||||
"incremental": true
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
|
||||
// 本配置文件的作用范围,包含根目录下的一切文件,包括 vite.config.ts 等配置文件
|
||||
"include": ["**/*.ts",],
|
||||
// 本配置文件排除的范围。
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
|
||||
Reference in New Issue
Block a user