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.

3
  • Which version of typescript are you using? Do you have a tsconfig file? If yes, what's the content of that one. Commented Apr 25, 2017 at 11:27
  • 2.1 and yes I have. Solved it myself just now if you see my answer. Commented Apr 25, 2017 at 11:35
  • 1
    That's exactly where I was going to bring you. Glad you solved it! Commented Apr 25, 2017 at 12:10

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.