4
我想使用異步/等待功能與angular2-webpack-starer和typescript(現在有這個功能針對ES5的支持),但我發現了錯誤: 異步/ AWAIT __generator沒有定義
這是組件內的代碼:
// function inside component
async checkSlug(slug: string) {
// nothing here
}
我正在使用webpack2.2和typescript 2.1.5。這是我的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 }
}
你告訴編譯器不產生輔助功能爲你' 「noEmitHelpers」:TRUE'。如果你將它設置爲false,它應該工作。否則,你需要提供幫助功能。見https://blog.mariusschulz.com/2016/12/16/typescript-2-1-external-helpers-library – JohnnyHK