Search code examples
javascriptangulartypescriptconfigtsconfig

Compile error - Cannot find name 'Map' & more - Angular 2


I'm having issues with my Angular project. It was developed without Angular CLI and now I'm getting these errors, as it appears it can't find classes inside collection.d.ts:

Build:Cannot find name 'Map'.
Build:Cannot find name 'MapConstructor'.

and so on. My tsconfig.json is the following:

{
"compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "outDir": "build/",
    "skipLibCheck": true,
    "lib": [ "es6","dom" ]
},
"compileOnSave": true]
}

I've already searched online for a solution, targeting es6, es5, or adding other lib attributes. Solutions? Thanks


Solution

  • Try this combination : "target": "es5", "lib": ["es5", "es6", "es7", "DOM"],

    If that doesn't work try npm install --save-dev @types/core-js.

    Which Angular and CLI version are you running exactly ?