Using async generator methods leads to syntax errors
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- tooling
Research direction
Start in esotope.js at the expression-generation logic around lines 1484 and 1513, where async and generator methods are currently treated as mutually exclusive. Reproduce the issue with the async generator example and run the TestCafe tests; done means the generated code preserves both keywords and no longer raises the syntax error.
Written by the indexing model from the issue text.
Description
My application code contains some async generator methods, e.g.:
export default {
async *generator(param) { /* ... */ }
}
The bundled code is valid and the application starts correctly. However, when running the TestCafe tests, I get a SyntaxError: Unexpected reserved word because the async keyword has been dropped. The reason is that async methods and generator methods are treated as mutually exclusive here and here. To make the TestCafe tests run, I had to patch this library as follows:
diff --git a/node_modules/esotope-hammerhead/esotope.js b/node_modules/esotope-hammerhead/esotope.js
index f8f4a37..dea67f9 100644
--- a/node_modules/esotope-hammerhead/esotope.js
+++ b/node_modules/esotope-hammerhead/esotope.js
@@ -1481,7 +1481,9 @@ var ExprRawGen = {
}
else {
- if ($expr.value.generator)
+ if ($expr.value.generator && $expr.value.async)
+ _.js += exprJs + 'async *' + keyJs;
+ else if ($expr.value.generator)
_.js += exprJs + '*' + keyJs;
else if ($expr.value.async)
_.js += exprJs + 'async ' + keyJs;
@@ -1510,7 +1512,9 @@ var ExprRawGen = {
_.js += keyJs;
else if ($expr.method) {
- if ($val.generator)
+ if ($val.generator && $val.async)
+ keyJs = 'async *' + keyJs;
+ else if ($val.generator)
keyJs = '*' + keyJs;
else if ($val.async)
keyJs = 'async ' + keyJs;
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·