angular: Angular 2.0.0-rc.5, @angular/router 3.0.0-rc.1, TS2304: Cannot find name 'Set', 'Map', 'Promise', 'MapConstructor' and 'SetConstructor'.
I’m submitting a
[x] bug report
[ ] feature request
[ ] support request
Environment
- Angular version: 2.0.0-rc.5
- Language: TypeScript 1.8.10 | ES5
- npm version: 3.10.6
- typings version: 1.3.2
Issue
The single LOC in below app.routing.ts giving me following compile error.
app.routing.ts
import { Routes, RouterModule } from "@angular/router";
C:\Users\Jaliya\Desktop\TestApp\src\TestApp.WebApp\wwwroot\app>tsc app.routing.ts
../../node_modules/@angular/common/src/directives/ng_class.d.ts(81,34): error TS2304: Cannot find name 'Set'.
../../node_modules/@angular/common/src/facade/lang.d.ts(11,17): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/common/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Set'.
../../node_modules/@angular/common/src/facade/lang.d.ts(67,59): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/common/src/pipes/async_pipe.d.ts(41,38): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/application_init.d.ts(16,18): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/application_ref.d.ts(99,88): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/application_ref.d.ts(134,67): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/application_ref.d.ts(150,109): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/application_ref.d.ts(202,67): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/application_ref.d.ts(204,109): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/application_ref.d.ts(236,42): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/application_ref.d.ts(331,33): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(28,16): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/di/reflective_provider.d.ts(108,123): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/di/reflective_provider.d.ts(108,165): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'.
../../node_modules/@angular/core/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'.
../../node_modules/@angular/core/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/collection.d.ts(100,41): error TS2304: Cannot find name 'Set'.
../../node_modules/@angular/core/src/facade/collection.d.ts(101,22): error TS2304: Cannot find name 'Set'.
../../node_modules/@angular/core/src/facade/collection.d.ts(102,25): error TS2304: Cannot find name 'Set'.
../../node_modules/@angular/core/src/facade/lang.d.ts(11,17): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Set'.
../../node_modules/@angular/core/src/facade/lang.d.ts(67,59): error TS2304: Cannot find name 'Map'.
../../node_modules/@angular/core/src/linker/compiler.d.ts(47,76): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/compiler.d.ts(62,57): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/compiler.d.ts(70,73): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/component_resolver.d.ts(22,58): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(67,148): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(108,144): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(113,139): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(114,135): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/ng_module_factory_loader.d.ts(14,34): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.ts(11,25): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/systemjs_component_resolver.d.ts(23,53): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/core/src/linker/systemjs_component_resolver.d.ts(36,53): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/router/src/interfaces.d.ts(54,99): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/router/src/interfaces.d.ts(112,109): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/router/src/interfaces.d.ts(157,115): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/router/src/interfaces.d.ts(192,91): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/router/src/interfaces.d.ts(238,50): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/router/src/router.d.ts(225,70): error TS2304: Cannot find name 'Promise'.
../../node_modules/@angular/router/src/router.d.ts(247,59): error TS2304: Cannot find name 'Promise'.
../../node_modules/rxjs/Observable.d.ts(10,66): error TS2304: Cannot find name 'Promise'.
../../node_modules/rxjs/Observable.d.ts(66,60): error TS2304: Cannot find name 'Promise'.
../../node_modules/rxjs/Observable.d.ts(66,70): error TS2304: Cannot find name 'Promise'.
Project Files
package.json
{
"version": "1.0.0",
"name": "asp.net",
"scripts": {
"postinstall": "typings install",
"typings": "typings"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.5",
"systemjs": "0.19.36",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.14",
"bootstrap": "^3.3.7"
},
"devDependencies": {
"del": "^2.2.2",
"gulp": "^3.9.1",
"typescript": "^1.8.10"
}
}
tsconfig.json
{
"compilerOptions": {
"noImplicitAny": true,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node"
},
"compileOnSave": true
}
typings.json
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160815222444"
}
}
Was trying out different ways like targeting ES6, but couldn’t get it to working. Appreciate any help on this.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (3 by maintainers)
You need to install the typings
npm install -g typings --save
Then in your project folder
typings install
using ‘typings’ cli did not resolve the issue for me when using angular 2.4.1. It seems angular2 has changed the way it deals with typings dependencies and instead of relying on typings definitions from the typings cli, it’s done through npm and the
tsconfig.json
file. So you no longer need to install thetypings
npm module. Instead install the@types/core-js
npm package:Make sure your tsconfig.json file has the ‘types’ property defined. Here’s what my tsconfig.json file looks like. You may have to modify the path to
typeRoots
to add/remove …/ depending on your setup.Hey, @bogusred, I am also running into this issue with 2.4.1. I configured “typeRoots” to match my setup, but I am getting error TS2688: Cannot find type definition file for ‘core-js’. Any suggestions?
Update: i was missing “lib”: [“es2015”, “dom”] from my compilerOptions. Now compilation is successful. I noticed that I didn’t need “types” set and that the Angular Quickstart tutorial doesn’t set that property either.
+1