Fix code generation for async generator methods (#6998)

Fixes generator to write `async *foo() {}` instead of `*async foo() {}`.
This commit is contained in:
Diogo Franco
2017-12-08 17:38:31 +09:00
committed by GitHub
parent 468aecca21
commit 2958548c2c
4 changed files with 56 additions and 6 deletions

View File

@@ -31,12 +31,6 @@ export function _methodHead(node: Object) {
const kind = node.kind;
const key = node.key;
if (kind === "method" || kind === "init") {
if (node.generator) {
this.token("*");
}
}
if (kind === "get" || kind === "set") {
this.word(kind);
this.space();
@@ -47,6 +41,12 @@ export function _methodHead(node: Object) {
this.space();
}
if (kind === "method" || kind === "init") {
if (node.generator) {
this.token("*");
}
}
if (node.computed) {
this.token("[");
this.print(key, node);

View File

@@ -0,0 +1,19 @@
function a() {}
function *b() {}
async function c() {}
async function *d() {}
var e = function () {};
var f = function *() {};
var g = async function () {};
var h = async function *() {};
class A {
a() {}
*b() {}
async c() {}
async *d() {}
e = () => {};
// f = () =>* {};
g = async () => {};
// h = async () =>* {};
}

View File

@@ -0,0 +1,30 @@
function a() {}
function* b() {}
async function c() {}
async function* d() {}
var e = function () {};
var f = function* () {};
var g = async function () {};
var h = async function* () {};
class A {
a() {}
*b() {}
async c() {}
async *d() {}
e = () => {}; // f = () =>* {};
g = async () => {}; // h = async () =>* {};
}

View File

@@ -0,0 +1 @@
{ "plugins": ["asyncGenerators", "classProperties"] }