Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

async/await __generator is not defined

I am trying to use async/await functions with angular2-webpack-starer and typescript (which now have support for this functions targeting es5), but I'm getting error: enter image description here

This is code inside component:

// function inside component
async checkSlug(slug: string) {
       // nothing here
}

I am using webpack2.2 and typescript 2.1.5. This is my tsconfig:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "noEmit": true,
    "noEmitHelpers": true,
    "strictNullChecks": false,
    "baseUrl": "./src",
    "paths": {
    },
    "lib": [
      "dom",
      "es7",
      "es2015.promise"
    ],
    "types": [
      "hammerjs",
      "jasmine",
      "node",
      "protractor",
      "selenium-webdriver",
      "source-map",
      "uglify-js",
      "webpack",
      "chai",
      "chai-as-promised",
      "lodash"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": { "rewriteTsconfig": false }
}
like image 581
Dariusz Filipiak Avatar asked Oct 18 '22 18:10

Dariusz Filipiak


1 Answers

Ok, this tsconfig.json works

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "noEmit": true,
    "noEmitHelpers": false,
    "strictNullChecks": false,
    "baseUrl": "./src",
    "paths": {
    },
    "lib": [
      "dom",
      "es7",
      "es5",
      "es2015.promise"
    ],
    "types": [
      "hammerjs",
      "jasmine",
      "node",
      "protractor",
      "selenium-webdriver",
      "source-map",
      "uglify-js",
      "webpack",
      "chai",
      "chai-as-promised",
      "lodash"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": { "rewriteTsconfig": false }
}
like image 102
Dariusz Filipiak Avatar answered Oct 29 '22 22:10

Dariusz Filipiak