user3506588 user3506588 - 11 months ago 42
TypeScript Question

Angular 2 cannot find file name 'Set'

Currently, I am updating my project from angular2 beta15 to rc4. When I am compiling, I am getting an error:

path/node_modules/@angular/common/src/directives/ng_class.d.ts(81,35): error TS2304: Cannot find name 'Set'.

My tsconfig.json looks as following:

"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": false,
"declaration": true,
"outDir": "tmp/app"
"exclude": [

in main.ts I also have included:

/// <reference path="../typings/index.d.ts" />
/// <reference path="../typings/tsd.d.ts"/>

and typings.json:

"name": "my-project",
"dependencies": {},
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160602141332",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160621231320",
"moment": "registry:dt/moment#2.8.0+20160316155526",
"moment-node": "registry:dt/moment-node#2.11.1+20160329220348",
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"

This error is gone when I change "target": "ES5" to "ES6" in tsconfig.json, but I need to use ES5. I assume the issue comes up when I do not include
///<reference path="../../node_modules/angular2/typings/browser.d.ts"/>
However, according to, we can use

Could you please share you opinion to solve this issue? Thank you very much in advance.

Answer Source

I think that Set is provided by the polyfill for ES6. Angular2 recommends using core-js for this (see

We begin with core-js's ES2015/ES6 shim which monkey patches the global context (window) with essential features of ES2015 (ES6)

You can specify it within your typings.json file but you need to install typings using the command typings install.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download