繁体   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