Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 5ed8573

Browse files
soda0289JamesHenry
authored andcommitted
Fix: Async generator method should be labeled (fixes #297) (#299)
1 parent 31ad3c4 commit 5ed8573

File tree

5 files changed

+862
-1
lines changed

5 files changed

+862
-1
lines changed

lib/convert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ module.exports = function convert(config) {
704704
method = {
705705
type: AST_NODE_TYPES.FunctionExpression,
706706
id: null,
707-
generator: false,
707+
generator: !!node.asteriskToken,
708708
expression: false,
709709
async: nodeUtils.hasModifier(SyntaxKind.AsyncKeyword, node),
710710
body: convertChild(node.body),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
module.exports = {
2+
"type": "Program",
3+
"range": [
4+
1,
5+
27
6+
],
7+
"loc": {
8+
"start": {
9+
"line": 2,
10+
"column": 0
11+
},
12+
"end": {
13+
"line": 4,
14+
"column": 1
15+
}
16+
},
17+
"body": [
18+
{
19+
"type": "FunctionDeclaration",
20+
"range": [
21+
1,
22+
27
23+
],
24+
"loc": {
25+
"start": {
26+
"line": 2,
27+
"column": 0
28+
},
29+
"end": {
30+
"line": 4,
31+
"column": 1
32+
}
33+
},
34+
"id": {
35+
"type": "Identifier",
36+
"range": [
37+
17,
38+
20
39+
],
40+
"loc": {
41+
"start": {
42+
"line": 2,
43+
"column": 16
44+
},
45+
"end": {
46+
"line": 2,
47+
"column": 19
48+
}
49+
},
50+
"name": "foo"
51+
},
52+
"generator": true,
53+
"expression": false,
54+
"async": true,
55+
"params": [],
56+
"body": {
57+
"type": "BlockStatement",
58+
"range": [
59+
23,
60+
27
61+
],
62+
"loc": {
63+
"start": {
64+
"line": 2,
65+
"column": 22
66+
},
67+
"end": {
68+
"line": 4,
69+
"column": 1
70+
}
71+
},
72+
"body": []
73+
}
74+
}
75+
],
76+
"sourceType": "script",
77+
"tokens": [
78+
{
79+
"type": "Identifier",
80+
"value": "async",
81+
"range": [
82+
1,
83+
6
84+
],
85+
"loc": {
86+
"start": {
87+
"line": 2,
88+
"column": 0
89+
},
90+
"end": {
91+
"line": 2,
92+
"column": 5
93+
}
94+
}
95+
},
96+
{
97+
"type": "Keyword",
98+
"value": "function",
99+
"range": [
100+
7,
101+
15
102+
],
103+
"loc": {
104+
"start": {
105+
"line": 2,
106+
"column": 6
107+
},
108+
"end": {
109+
"line": 2,
110+
"column": 14
111+
}
112+
}
113+
},
114+
{
115+
"type": "Punctuator",
116+
"value": "*",
117+
"range": [
118+
16,
119+
17
120+
],
121+
"loc": {
122+
"start": {
123+
"line": 2,
124+
"column": 15
125+
},
126+
"end": {
127+
"line": 2,
128+
"column": 16
129+
}
130+
}
131+
},
132+
{
133+
"type": "Identifier",
134+
"value": "foo",
135+
"range": [
136+
17,
137+
20
138+
],
139+
"loc": {
140+
"start": {
141+
"line": 2,
142+
"column": 16
143+
},
144+
"end": {
145+
"line": 2,
146+
"column": 19
147+
}
148+
}
149+
},
150+
{
151+
"type": "Punctuator",
152+
"value": "(",
153+
"range": [
154+
20,
155+
21
156+
],
157+
"loc": {
158+
"start": {
159+
"line": 2,
160+
"column": 19
161+
},
162+
"end": {
163+
"line": 2,
164+
"column": 20
165+
}
166+
}
167+
},
168+
{
169+
"type": "Punctuator",
170+
"value": ")",
171+
"range": [
172+
21,
173+
22
174+
],
175+
"loc": {
176+
"start": {
177+
"line": 2,
178+
"column": 20
179+
},
180+
"end": {
181+
"line": 2,
182+
"column": 21
183+
}
184+
}
185+
},
186+
{
187+
"type": "Punctuator",
188+
"value": "{",
189+
"range": [
190+
23,
191+
24
192+
],
193+
"loc": {
194+
"start": {
195+
"line": 2,
196+
"column": 22
197+
},
198+
"end": {
199+
"line": 2,
200+
"column": 23
201+
}
202+
}
203+
},
204+
{
205+
"type": "Punctuator",
206+
"value": "}",
207+
"range": [
208+
26,
209+
27
210+
],
211+
"loc": {
212+
"start": {
213+
"line": 4,
214+
"column": 0
215+
},
216+
"end": {
217+
"line": 4,
218+
"column": 1
219+
}
220+
}
221+
}
222+
]
223+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
async function *foo() {
3+
4+
}

0 commit comments

Comments
 (0)