webpack TS2304 Cannot find name 'Map', 'Set', 'Promise'

cannot find name 'map typescript
error ts2583: cannot find name 'map
error ts2583: cannot find name 'set'.
cannot find name 'map' angular 7
cannot find name 'map'. do you need to change your target library?
cannot find name 'map' angular 8
try changing the lib compiler option to es2015 or later visual studio
error ts2552: cannot find name 'map'. did you mean 'map'?

I have the following webpack.config.js

var path = require("path");
var webpack = require('webpack');

module.exports = {
  entry: {
    'ng2-auto-complete': path.join(__dirname, 'src', 'index.ts')
  resolve: {
    extensions: ['', '.ts', '.js', '.json', '.css', '.html']
  output: {
    path: path.join(__dirname, 'dist'),
    filename: "[name].umd.js",
    library: ["[name]"],
    libraryTarget: "umd"
  externals: [
    /^rxjs\//,    //.... any other way? rx.umd.min.js does work?
  devtool: 'source-map',
  module: {
    loaders: [
      { // Support for .ts files.
        test: /\.ts$/,
        loaders: ['ts', 'angular2-template-loader'],
        exclude: [/test/, /node_modules\/(?!(ng2-.+))/]

and the following tsconfig.json

  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitHelpers": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "pretty": true,
    "allowUnreachableCode": true,
    "allowUnusedLabels": true,
    "noImplicitAny": false,
    "noImplicitReturns": false,
    "noImplicitUseStrict": false,
    "noFallthroughCasesInSwitch": false,
    "allowSyntheticDefaultImports": true,
    "suppressExcessPropertyErrors": true,
    "suppressImplicitAnyIndexErrors": true,
    "outDir": "dist",
    "baseUrl": "src"
  "files": [
  "exclude": [
  "compileOnSave": false,
  "buildOnSave": false

When I run tsc command as the following, it all works fine.

ng2-auto-complete (master)$ tsc --declaration
ng2-auto-complete (master)$ 

When I run webpack command, it shows typescript compile errors.

ng2-auto-complete (master)$ webpack
ts-loader: Using typescript@2.0.0 and /Users/allen/github/ng2-auto-complete/tsconfig.json
Hash: bd6c50e4b9732c3ffa9d
Version: webpack 1.13.2
Time: 5041ms
                       Asset     Size  Chunks             Chunk Names
    ng2-auto-complete.umd.js  24.4 kB       0  [emitted]  ng2-auto-complete
ng2-auto-complete.umd.js.map  28.4 kB       0  [emitted]  ng2-auto-complete
    + 11 hidden modules

ERROR in /Users/allen/github/ng2-auto-complete/node_modules/@angular/platform-browser/src/dom/dom_renderer.d.ts
(18,37): error TS2304: Cannot find name 'Map'.

ERROR in /Users/allen/github/ng2-auto-complete/node_modules/@angular/platform-browser/src/dom/dom_adapter.d.ts
(96,42): error TS2304: Cannot find name 'Map'.

ERROR in /Users/allen/github/ng2-auto-complete/node_modules/@angular/platform-browser/src/web_workers/worker/location_providers.d.ts
(21,86): error TS2304: Cannot find name 'Promise'.
ng2-auto-complete (master)$ 

I don't know what I am missing for webpack and typescript compilation.

node_modules has been excluded in tsconfig.json

"exclude": [ "node_modules" ],

and type definitions are there in node_modules

  "devDependencies": {
    "@types/core-js": "^0.9.32",
    "@types/node": "^6.0.31"

I also tried to use typings.json and typings directory without success.

  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160725163759",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160815222444"

FYI, versions

$ node --version
$ npm --version
$ tsc --version
Version 2.0.0

How do I get rid of TS2304 errors with webpack command?

I added this to work in tsconfig.json, and it seems working without any error.

  "compilerOptions": {
    "target": "es5",
    "lib": ["es5", "es6", "dom"],  <--- this

I am not sure lib are for Typescript 2.0 function or not, but found out there are several libraries are available

From the typescript config schema (note the es2015.collection)

 "lib": {
      "description": "Specify library file to be included in the compilation. Requires TypeScript version 2.0 or later.",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [ "es5", "es6", "es2015", "es7", "es2016", "es2017", "dom", "webworker", "scripthost", "es2015.core", "es2015.collection", "es2015.generator", "es2015.iterable",
                    "es2015.promise", "es2015.proxy", "es2015.reflect", "es2015.symbol", "es2015.symbol.wellknown", "es2016.array.include", "es2017.object", "es2017.sharedmemory" ]

This solves the compile errors, but I still wonder why tsc command works without any errors, but webpack does not. tsc searches for all possible libraries without using lib by tsconfig.json?

error TS2304: Cannot find name 'Set'. 815 , D:\workshop\www λ node -v v8.12.0 D:\workshop\www λ npm -v 6.4.1 D:\​workshop\www λ npm install typescript -g  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more TS2304: cannot find name require and process

Map, Set and Promise are ES6 features. In your tsconfig.json you are using:

"target": "es5" 

This causes the compiler to use the normal es5 lib.d.ts, which lacks the definitions for the above types.

You want to use the lib.es6.d.ts:

"target": "es6" 

Typescript: Cannot find name 'RuleSetConditionsRecursive' · Issue , I get the error error “error TS2304: Cannot find name 'PropertyKey'” JSON.​stringify({ message: 'Go Serverless Webpack (Typescript) v1.0! React TypeScript Application gets 'TS2304: Cannot find name 'Text'.'. This is the dependencies in my package.json. this used to work for me in the past.

Just add:

 "lib": ["es6"] // means at least ES6

Don't change target. Target is used to tell Typescript into which version of ECMAScript to compile your .ts files. Of course, you can change it, if the browser your application will be running in, will support that version of ECMAScript.

For example, I use "target": "es5" and "lib": ["es6"].

Another reason could be:

That your .ts file is not under "rootDir": "./YourFolder",

Visual Studio 2015, I had that issue and the root cause was from my tsconfig.json adding node to list compilerOptions.types solve the issue. I'm getting this too after upgrading to antd 2.10.4. It wasn't happening with antd 2.10.1. The default export in the lib/table/Column.d.ts file has changed which TS complains about.

If you are wondering why none of these fixes work for you keep in mind -- if you specify the file to compile on the command line or package.json tsc will NOT read your tsconfig.json file and therefore have no effect. Instead specify the "files" and "outDir" in your tsconfig.json and one of the "lib" fixes will probably work for you. Then compile with only:

tsc --sourcemaps

Aws-nodejs-typescript, error TS2583: Cannot find name 'Map'. (C:\Users\Admin\Desktop\angular\​node_modules\#angular\cli\models\webpack-configs\typescript.js:77:16) at Object. TS2304: Cannot find name 'SetConstructor'. As far as I knew, the issue was indeed related to the recent upgrade I made switching Angular2 beta to Angular2 RC1. I managed to fix that, but it took a fair amount of time due to the lack of documentation almost anywhere.

tsc index.ts --lib "es6"

If adding lib not working in tsconfig.json, using above command line option

[Solved]create react app typescript TS2304: Cannot find name , Typescript getting error TS2304 cannot find name ' require' - When we try to get a TypeScript running, we get this error: npm install @types/node --save-dev  I always have this hassle with every node/typescript project starting up. I thought that. typings install --global --save dt~node. should get TS & node to work together but something fragile seems to have broken.

error TS2583: Cannot find name 'Map'. Do you need to change your , I added this to work in tsconfig.json , and it seems working without any error. "​compilerOptions": { "target": "es5", "lib": ["es5", "es6", "dom"], <--- this } I am not  amoshydra changed the title tCannot find name 'RuleSetConditionsRecursive' Typescript: Cannot find name 'RuleSetConditionsRecursive' Jan 5, 2020 This comment has been minimized. Sign in to view

Typescript getting error TS2304 cannot find name ' require', Webpack. If you are using Webpack as your build tool you can include the Webpack types. npm install –save-dev @types/webpack-  @voxmatt @vidartf @losnir it appears that at-loader isn't correctly handling the @types declarations because of the location of the tsconfig.json file being different than what it expects (ie, in the same folder that also contains node_modules).

webpack TS2304 Cannot find name 'Map', 'Set', 'Promise', Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

  • ES6 lib is the only one needed to make it work. In case you are encountering the same problem running typescript with node
  • you should select your answer as the preferred solution
  • Thank you I am Search Guru.Your answer was the best
  • This fixed my issue too, thanks!
  • Based on here, target should be 'es5' to generate es5 code. if target is es6, will it still work with lower browser, e.g., 'IE11'?
  • No, and not all browsers support the newest es6 features as well. But if you want to use es6 features such as Promise and Map then you need to target es6 or copy the definitions of what you need from the libe.es6.d.ts
  • Then, if we want to satisfy IE11, es6 objects; Map, Promise ,should be converted to es5 objects. Thus, the target should be es5 not es6. Am I right?
  • Its not the "target" that picks up the library but the "lib" should include the library for those objects. Look at @allenhwkim s answer. that solves the issue and is the right answer.
  • My point is that "target" is to specify what the output type should be (es5 in case of OP) and "lib" is to specify the libraries that webpack should use to compile the source code. Your answer/comment seems to make it sound as if the "target" is to specify the libs.
  • Note that the lib option has more than one library by default; as they are, the examples above will drop other default libraries such as DOM and ScriptHost (and DOM.Iterable for ES6 targets).
  • Superb. Thanks very much.
  • Winner, after reading all that this was the last post and was the one that made me go "oh duh" and fixed it. Thanks
  • Its working for me with the option 2
  • Note that typings is deprecated since TypeScript 2.0. Use @types instead.