tsc not excluding node_modules

2019-02-17 00:38发布

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

I'm trying to upgrade an angular2/beta8 app to RC1, and I'm doing so by basically restructuring according to the Quickstart guide.

I copied its tsconfig.json into my project directory. I think I've got everything else ready,but when I run tsc, I get all kinds of errors within files in my node_modules folder. Why is it even looking in there in the first place?

1条回答
Explosion°爆炸
2楼-- · 2019-02-17 00:56

I don't know if you found an answer to this Alex but the referred to question/answer in the comments by LDL provides an answer, submitted by Srikanth Injarapu.

Here's the answer just in case someone doesn't feel like going to that link:

If you're targeting ES5, add "node_modules/typescript/lib/lib.es6.d.ts" to tsconfig.json file :

 {    
   "compilerOptions": {
     "module": "commonjs",
     "target": "es5",
     "noImplicitAny": false,
     "outDir": "built",
     "rootDir": ".",
     "sourceMap": false
   },
   "files": [
     "helloworld.ts",
     "node_modules/typescript/lib/lib.es6.d.ts"
   ],
   "exclude": [
     "node_modules"
   ]
 }

EDIT

In my application I make use of webpack to build my app and I still get the same errors being spat out on the console. I'm currently looking in to fixing this and will report back with what I find.

查看更多
登录 后发表回答