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

后端 未结 15 2334
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 07:07

I have the following webpack.config.js

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

module.exports = {
  entry: {
    \'ng2-auto-comple         


        
15条回答
  •  醉话见心
    2020-12-01 07:50

    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?

提交回复
热议问题