Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 2.0.0-rc.5, @angular/router 3.0.0-rc.1, TS2304: Cannot find name 'Set', 'Map', 'Promise', 'MapConstructor' and 'SetConstructor'. #10891

Closed
jaliyaudagedara opened this issue Aug 17, 2016 · 15 comments

Comments

@jaliyaudagedara
Copy link

jaliyaudagedara commented Aug 17, 2016

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.

@brandonroberts
Copy link
Contributor

You need to install the typings

npm install -g typings --save

Then in your project folder

typings install

@pkozlowski-opensource
Copy link
Member

Thnx @brandonroberts !

@jaliyaudagedara
Copy link
Author

@brandonroberts, I am sorry, typings were already installed. In the package.json, you can see that on the post install, I have mentioned to install typings. typings folder is getting created and it's in the same level as typings.json.

@jaliyaudagedara
Copy link
Author

jaliyaudagedara commented Aug 18, 2016

@pkozlowski-opensource, could you please reopen the issue. It's sad to see an issue being closed without verification.

@brandonroberts
Copy link
Contributor

@jaliyaudagedara if you need further assistance come into the support channel at https://gitter.im/angular/angular

@jaliyaudagedara
Copy link
Author

@brandonroberts, thanks. Joining in!

@rohanchandane
Copy link

I was getting similar issue while running gulp task which was compiling ts. Solution from 'Akash' worked for me here http://stackoverflow.com/questions/33696885/typescript-gulp-task-error

@Eachawy
Copy link

Eachawy commented Oct 20, 2016

@brandonroberts Many Thanks man

@abhiindian
Copy link

I also faced the similar issue.... I resolved it by installing

npm install -g typings --save

Then in your project folder

typings install

Also make sure that your need the latest typescript compiler. I am using Typescript 2.1.4

@bogusred
Copy link

bogusred commented Jan 2, 2017

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 the typings npm module. Instead install the @types/core-js npm package:

npm install --save-dev @types/core-js

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.

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": [
      "../../node_modules/@types/"
    ],
    "types" : [
      "core-js"
    ]
  },
  "compileOnSave": true,
  "exclude": [
    "node_modules/*",
    "**/*-aot.ts"
  ]
}

@hendryau
Copy link

hendryau commented Jan 15, 2017

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.

@AinoL
Copy link

AinoL commented Mar 14, 2017

+1

@bogusred
Copy link

It's also helpful to use the angular cli to generate a blank project and then copy+paste configs from there into your existing project. That's what I ended up doing after my last message and things seem to run smoother.

@lamjar
Copy link

lamjar commented Dec 27, 2017

install
npm install typings --save
and change target to es6 in your tsconfig.json:

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
    }
}

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants