-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for top-level-for-await #3212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely ! I believe there are a couple of examples in the manual that could benefit from this feature. Would you mind editing those too?
Ok, I added in a few places I saw it. Assuming this should be preferred over window.onload... I also discovered the ws README example code was broken, so I ported it over from the examples. Although it may be better just to delete it (and point to those examples). _048_media_types_jsx failed in the first commit, presumably it's this: Lines 71 to 72 in 51dd91a
(This particularly test requires the http_server to be up at compile time.) |
const body = new TextEncoder().encode("Hello World\n"); | ||
for await (const req of serve(":8000")) { | ||
req.respond({ body }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sexy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Looks like top-level for-await already works with js. This PR allows it in typescript files too.
Unfortunately prettier/babel doesn't accept it (eslint does). So the js test file is ignored... Confusingly the ts file doesn't suffer with the same issue.
I'm not sure a good resolution going forward but am putting the PR up anyways.
cc #471