PatrickJS-starter icon indicating copy to clipboard operation
PatrickJS-starter copied to clipboard

Cannot find name error when running with target es5

Open gaurav2887 opened this issue 10 years ago • 3 comments

Hi All,

I am getting following error when running the project using npm run server:dev.

My tsconfig.json file: "target": "es5"

Error: Cannot find name 'Map'. Cannot find name 'Promise'. Cannot find name 'Set'.

If I change target to es6 then error goes away but my app stopped working in Internet explorer. Is there any way I can get rid of these error keeping es5 target?

I have also tried typings install but no luck.

gaurav2887 avatar Sep 13 '16 23:09 gaurav2887

Hey, I had this issue too using WebStorm. The problem is that the lib option doesn't seem to be supported (see this issue). What I did was remove the lib option and put core-js inside the types option. My tsconfig file looks like this:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "noEmitHelpers": true,
    "strictNullChecks": false,
    "baseUrl": "./src",
    "paths": {
        "core": ["app/core"],
        "shared": ["app/shared"]
    },
    "types": [
      "lodash",
      "core-js",
      "hammerjs",
      "jasmine",
      "node",
      "protractor",
      "selenium-webdriver",
      "source-map",
      "uglify-js",
      "webpack"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": { "rewriteTsconfig": false }
}

If this isn't the best work-around, please let me know.

exk0730 avatar Sep 14 '16 14:09 exk0730

@exk0730 - That was it.. It's working now with no errors.. Thanks a lot

gaurav2887 avatar Sep 14 '16 16:09 gaurav2887

better you upgrade the typescript version in WebStorm:

update_typescriptversion_in_webstorm

nxpatterns avatar Nov 03 '16 10:11 nxpatterns