typescript tsc is not excluding @types/corejs

typescript tsc is not excluding @types/corejs

本文关键字:@types corejs excluding not tsc is typescript      更新时间:2023-09-26

Tsconfig:

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noEmitHelpers": true,
"lib": [
  "es6",
  "dom"
],
"types": [
  "hammerjs",
  "jasmine",
  "node",
  "selenium-webdriver",
  "webpack",
  "core-js",
  "google-maps"
]
},
"exclude": [
"node_modules"
"e2e"
],
"include": [
"src/**/*"
],
"filesGlob": [
"./src/**/*.ts",
"./test/**/*.ts",
"!./node_modules/**/*.ts",
"./src/custom-typings.d.ts"
],
}

当执行tsc时,我得到以下错误:

node_modules/@types/core js/index.d.ts(262,5(:错误TS2687:"flags"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(276,5(:错误TS2687:"EPSILON"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(311,5(:错误TS2687:"MAX_SAFE_INTEGER"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(318,5(:错误TS2687:"MIN_SAFE_INTEGER"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(457.5(:错误TS2403:后续变量声明必须具有相同的类型。变量"[Symbol.toStringTag]"的类型必须为"Symbol",但此处的类型为"string"。node_modules/@types/core js/index.d.ts(457.5(:错误TS2687:"[Symbol.toStringTag]"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(464,5(:错误TS2687:"prototype"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(492,5(:错误TS2687:"hasInstance"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(498,5(:错误TS2687:"isConcatSpreadable"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(504,5(:错误TS2687:"迭代器"的所有声明都必须具有相同的修饰符。node_modules/@types/core js/index.d.ts(510,5(:错误TS2687:的所有声明

为什么在执行tsc命令时不忽略node_modules。我在2.0.3版本中使用typescript

tsconfig.json文件在"types"属性中列出core-js。这指示编译器包含node_module'@types'core-js。如果您不需要它,请删除该条目。

请参阅http://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-关于@typestsconfig.json中的types的更多细节。