1

I have this snippet of code below which generates this error: Cannot find name 'Map'

let scriptMap = new Map();

I had a similar error before with this code Cannot find name 'Promise'. Solved it by running npm install --save @types/es6-promise.

let promise = new Promise((resolve: any, reject: any) => {
                    let resolved = false,

I find a lot of good answers to solve it with Angular 2 here but not otherwise. If I run npm install --save @types/core-js I get a lot more errors than the one I have now. I do not wan't to set my target to es6 in tsconfig.json if I don't have to.

Community
  • 1
  • 1
Ogglas
  • 62,132
  • 37
  • 328
  • 418

1 Answers1

4

Uninstalled es6-promise to avoid duplicates and then added "lib": [ "es5", "es6", "dom" ] to tsconfig.json solved it.

Ogglas
  • 62,132
  • 37
  • 328
  • 418
  • 2
    That's exactly how you do it :) Maybe to clarify: The used `libs` depend on your `target` configuration. For `ES5`: `DOM,ES5,ScriptHost` are included and for `ES6` it's `DOM,ES6,DOM.Iterable,ScriptHost`. – Sebastian Sebald Apr 25 '17 at 11:36