Ogglas
Ogglas

Reputation: 70126

Cannot find name 'Map' TypeScript React

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.

Upvotes: 1

Views: 1045

Answers (1)

Ogglas
Ogglas

Reputation: 70126

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

Upvotes: 4

Related Questions