问题
Currently I am facing issue with one of the modules inside node_modules while r compiling the Angular 4 Project and the getting the error as below hence I decided to exclude this project in the tsconfig.json but still I am getting the error, Can someone help me here
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'
Hence I decided to exclude the node_modules to avoid these errors but still I am facing the same error when running 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/*"
]
}
回答1:
you should add skipLibCheck
it skips type checking of all declaration files (*.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"
]
}
来源:https://stackoverflow.com/questions/50588726/angular-typescript-exclude-is-not-working-in-tsconfig-json