簡體   English   中英

Angular Typescript - exclude在tsconfig.json中不起作用

[英]Angular Typescript - exclude is not working in tsconfig.json

目前我正面臨node_modules中的一個模塊的問題,而r編譯Angular 4項目並得到如下錯誤,因此我決定在tsconfig.json中排除這個項目,但我仍然得到錯誤,有人可以幫我嗎這里

ERROR in D:/workspace/demo/node_modules/@types/d3-collection/index.d.ts (148,23): ',' expected.

ERROR in D:/workspace/demo/node_modules/@types/d3-collection/index.d.ts (483,40): ',' expected.

ERROR in D:/workspace/demo/node_modules/@types/d3-collection/index.d.ts (148,25): Type parameter name cannot be 'any'

因此我決定排除node_modules以避免這些錯誤,但在運行npm start時我仍面臨同樣的錯誤

tsconfig.json

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es6",
      "dom"
    ],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ]
  },
  "exclude": [
    "**/node_modules/*"
  ]
}

你應該添加skipLibCheck它跳過所有聲明文件(* .d.ts)的類型檢查。

https://www.typescriptlang.org/docs/handbook/compiler-options.html

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es6",
      "dom"
    ],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "skipLibCheck": true,
    "types": ["d3-collection"]
  },
  "exclude": [
    "node_modules"
  ]
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM