-
Notifications
You must be signed in to change notification settings - Fork 507
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
"Error: 'return' outside of function" with async/await #869
Comments
Minimal ReproductionThanks for submitting this bug and reproduction @seungdols . I've successfully reproduced this with TSDX v0.13.3 with a much more minimal example: ;(async () => {
await 0
})() And got the same error. Bug + PRThis is actually a bug upstream in I'm actually working on a PR to fix all these issues (by removing usage of that plugin) literally right now in #795 , so unfortunately you hit this just before it was fixed 😅 . The bright side is that this is another regression test I can use in #795 which is the last part I'm finishing up right now.
TSDX doesn't control this message, and neither does Workarounds Available
Fortunately, you don't need to wait for #795 and the next release to fix this. You can change to a different syntax which avoids the upstream bug: const puppeteer = require('puppeteer')
- ;(async () => {
+ ;(async function test() { // <---------- this is an equivalent syntax that doesn't hit this bug
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://example.com')
await page.screenshot({ path: 'example.png' })
await browser.close()
})() Misc Notes
It's really important to write the full output of the command given in the issue template. It is there for a reason. It doesn't seem like you ran it at all since its output is not formatted / does not look like this...
Example code wouldn't be imported by consumers of a library, so I'm not sure why you actually need to build this at all. |
@allcontributors please add @seungdols for bug |
I've put up a pull request to add @seungdols! 🎉 |
For your specific purpose, since node 10 |
@agilgur5 Thank you for explaining in detail. Actually, I tried to find this bug, but I still don't understand the structure of the project, but you solved it. Thanks to the kind explanation, it was an opportunity to understand the project more. It was really good for teaching. thank you.😁 |
Current Behavior
Hello! Thank you for making this awesome tool.
By the way, an error occurred while testing to set up the project using this tool.
Expected behavior
If you build using tsc, it is a code that builds normally.
Why this error message?
I can’t build a module of puppeteer example code.
I would like to know why the error occurs in a simple async/await code.
And I couldn't understand exactly what the error message was saying, so I had to ask a question.
What exactly did I do wrong with this error message? I don't know, can you change the message a little more kindly?
And can you guide me on how to solve this problem?
Your environment
The text was updated successfully, but these errors were encountered: