ui-router: typescript compilation errors "Cannot find name 'Promise'"

error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/ng1/directives/viewDirective.d.ts
(8,17): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/ng1/statebuilders/views.d.ts
(40,66): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/state/stateService.d.ts
(74,39): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/transition/transitionHook.d.ts
(15,1919): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/transition/transitionHook.d.ts
(21,40): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/transition/transitionHook.d.ts
(28,87): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/transition/interface.d.ts
(209,66): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/view/interface.d.ts
(48,13): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/resolve/resolveContext.d.ts
(76,57): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/resolve/resolvable.d.ts
(25,14): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/resolve/resolvable.d.ts
(66,62): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/state/interface.d.ts
(12,44): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/transition/transition.d.ts
(37,14): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/transition/transition.d.ts
(232,12): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/common/common.d.ts
(333,58): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/common/common.d.ts
(333,75): error TS2304: Cannot find name 'Promise'<project_root>/node_modules/angular-ui-router/commonjs/common/common.d.ts

package version 1.0.0-beta.1

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I recommend using typescript 2.0+ and adding to your tsconfig.json:

{ 
  "compilerOptions": {
    "lib": ["es2015", "dom"]
  }
}

This tells typescript to use the .d.ts files from /node_modules/typescript/lib/lib.<library>.d.ts

try typings install --global dt~es6-shim

Let me know if it works or not.

@ivanvoznyakovsky Fixed it by installing es6-shim typings

Or just include it in your package.json @types/es6-promise (In typescript 2.x)

npm i --save @types/es6-promise

node_modules/@types/selenium-webdriver/remote.d.ts(139,29): error TS2304: Cannot find name ‘Map’.

i fix by removing in Map<string, string> | in setEnvironment(env: Map<string, string> | {[name: string]: string} | null):

At file “tsconfig.json” try one of these options:

  • if “target”: “es5” add , “lib”: [ “es6” ]
  • or change “target”: “es5” to “target”: “es6”

This worked for me

  1. npm install typings --global

  2. typings install --global dt~es6-shim

  3. then I added - “lib”: [“es2015”, “dom”] to compilerOptions . Now it builds fine without those errors.