Async / wait __generator not defined

I am trying to use the asynchronous / await function with angular2 -webpack-starer and <a href = "https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#downlevel-async-functions" rel = "NOFOLLOW noreferrer"> typescript (which now has support for this ES5 targeting function), but I get an error: enter image description here

This is the code inside the 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 }
}
+4
source share
1 answer

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 }
}
+3
source

Source: https://habr.com/ru/post/1667650/


All Articles