Remove top-level async function in TS script examples
See original GitHub issueTS now supports top-level await: https://twitter.com/typescript/status/1230629807991341058?s=12
We should consider removing the top-level async main
function in the TS script example.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
javascript - How can I use async/await at the top level?
Use top-level await (proposal, MDN; ES2022, broadly supported in modern environments) that allows top-level use of await in a module.
Read more >Typescript top level await - YouTube
Typescript top level await let you write await directly without the need of an async function wrapper. This will allow you to write...
Read more >await - JavaScript - MDN Web Docs
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async...
Read more >Use Promise.all to Stop Async/Await from Blocking Execution ...
Heads up! There are ways to clean this up, such as pulling out the functions passed to .then into to top-level scope and...
Read more >TypeScript's New Top-Level Await - Better Programming
In this article, I want to show you that it is possible to finally use top-level await instead of wrapping it between an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Update about top-level await: I just talked to Andrew from the TypeScript team, and it looks like it’s not yet what we think it is.
So what this PR just did, is making sure, that top level await is “not transformed” anymore. That means, if you have top-level await in your TS code, it will end up in the generated JS code.
In order to use it today, you need to provide the v8 flag
--harmony-top-level-await
. Another option he mentioned, is that you might get it running with--module=systemjs
, which we can investigate, but it doesn’t seem like an established thing yet, that we should recommend as the default.So it seems like Node is just not ready yet.
https://github.com/prisma/prisma-client-js/issues/540 is related as it makes calling
prisma.disconnect()
optional.