Enable await in ES6 and ES2015 script mode
Even though strictly generators are an ES6 feature the real world support is large enough to use the feature in well known environments like node.js or Electron app. Since the previous output was not working at all anyway it feels like a good compromise to at least emit working code while still having the warning in place. The user would also need to add "use strict" on top of her .ts file to make it work with node.js.
This commit is contained in:
parent
dac1874c38
commit
1fb8a249df
1 changed files with 28 additions and 26 deletions
|
@ -4526,8 +4526,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
emitSignatureParameters(node);
|
||||
}
|
||||
|
||||
// Even though generators are a ES6 only feature, the functionality is wiedely supported
|
||||
// in current browsers and latest node, therefore showing some tolerance
|
||||
const isAsync = isAsyncFunctionLike(node);
|
||||
if (isAsync && languageVersion === ScriptTarget.ES6) {
|
||||
if (isAsync && (languageVersion === ScriptTarget.ES6 || languageVersion === ScriptTarget.ES2015 || languageVersion === ScriptTarget.ES5)) {
|
||||
emitAsyncFunctionBodyForES6(node);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue