Cannot find global type 'IterableIterator' with Typescript 1.7.5

前端 未结 2 1681
终归单人心
终归单人心 2021-01-23 07:15

I installed NPM version of Typescript 1.7.5 and angular2 beta. While building the project in Visual Studio 2015 Update 1, I get this errors:

1>VSTSC : error T         


        
相关标签:
2条回答
  • 2021-01-23 07:44

    You seem to add lib.d.ts twice because you use noLib and you specifically add node_modules/typescript/lib/lib.d.ts in files.

    I would just remove "node_modules/typescript/lib/lib.d.ts" path.

    There is also an issue with similar errors as you get: https://github.com/Microsoft/TypeScript/issues/5504

    0 讨论(0)
  • 2021-01-23 07:49

    Usually when noLib is set to true and target is set to es6 it will include lib.es6.d.ts in addition to lib.d.ts. lib.es6.d.ts holds the definitions specific to ES6.

    However, you are including lib.d.ts, which has this statement at the top of that file:

    /// <reference no-default-lib="true"/>
    

    This overrides your tsconfig.json option and sets noLib to true; therefore, it doesn't include lib.es6.d.ts. This explains your errors.

    If you want to continue using the definition files from node_modules/typescript/..., then you need to include lib.es6.d.ts as well:

    "files": [
        "node_modules/angular2/typings/tsd.d.ts",
        "node_modules/angular2/typings/zone/zone.d.ts",
        "node_modules/angular2/core.d.ts",
        "node_modules/typescript/lib/lib.d.ts",
        "node_modules/typescript/lib/lib.es6.d.ts"
    ]
    

    Otherwise, follow Martin's answer by keeping noLib as false and remove the reference to lib.d.ts in the list of files.

    0 讨论(0)
提交回复
热议问题