Skip to content

Direct use await whitout async function #20923

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

Closed
11ume opened this issue Dec 28, 2017 · 3 comments
Closed

Direct use await whitout async function #20923

11ume opened this issue Dec 28, 2017 · 3 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@11ume
Copy link

11ume commented Dec 28, 2017

Hi, what possibilities exist to be able to use the await operator without the use of async?,
as it is currently done in javascript.

Example in actual javascript

const prom = new Promise((r)=> {r('Running whitout without async 🏄
')});
await prom // Running whitout without async 🏄

Regards!

@ajafff
Copy link
Contributor

ajafff commented Dec 28, 2017

as it is currently done in javascript.

@Hume83 do you mean what the node repl or chrome console does? There is some special treatment for top level await.
In regular JavaScript and TypeScript this is not valid. You can try it yourself by saving the code snippet to a file and execute that file with node.

@11ume
Copy link
Author

11ume commented Dec 28, 2017

You are right, excuse my ignorance, I have tried it fast in the console, it would be a really great feature, to avoid the unnecessary use of async function in some cases. Could this feature be available in the future of Javascript?
Thanks for your answer mate.

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Dec 28, 2017
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants