打字稿:排除对库文件夹的检查

时间:2016-07-15 07:07:45

标签: typescript angular

我正在运行一个带有打字稿的Angular 2项目,我的角网页模块出现了很多错误

[error] node-modules\webjars\@angular\common\src\directives\ng_class.d.ts:80: TS2304 Cannot find name 'Set'.
[error]     rawClass: string | string[] | Set<string> | {
[error]                                   ^
[error] node-modules\webjars\@angular\common\src\facade\async.d.ts:33: TS2304 Cannot find name 'Promise'.
[error]     static fromPromise(promise: Promise<any>): Observable<any>;
[error]                                 ^
[error] node-modules\webjars\@angular\common\src\facade\async.d.ts:34: TS2304 Cannot find name 'Promise'.
[error]     static toPromise(obj: Observable<any>): Promise<any>;
[error]       

显然,我不希望我的打字稿检查这些库,因此我设置了tsconfig.json如下:

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators":true,
    "sourceMap": true,
    "noImplicitAny":true,
    "noFallthroughCasesInSwitch":true,
    "noImplicitReturns":true,
    "outDir": "./target/ts"
  },
  "exclude": [
    "node_modules",
    "project/target",
    "typings/main",
    "typings/main.d.ts",
    "typings/browser",
    "target/web"
  ]
}

我还有什么要做的吗?

2 个答案:

答案 0 :(得分:2)

不完全确定为什么angular 2 quickstart tsconfig.json他们删除了exclude参数。但是,是的,你是对的。这就是你应该做的一切。 exclude曾经看起来像这样,在我看来,应该仍然是这样的:

tsconfig.json

...
"exclude": [
  "node_modules",
  "typings/globals"
]

答案 1 :(得分:0)

我设法通过添加回来解决问题:

.../angular2/typings/browser.d.ts in my typings.d.ts

我不知道的是,这个文件来自angular2(它是beta-17的一部分),我在最新的rc(4)中找不到与此相对应的任何内容。