Zero-operand await

Quite often I find myself writing await Promise.resolve() in an async function, particularly when writing tests for other async functions but also sometimes when I just want to delay execution until the next tick. The thing about this is that I know I can write await null, await 1 or await (expression) for much the same effect. However, I feel like the intention is not as clear with these other things, and I work with and mentor junior engineers who I know would be confused by it because you're awaiting a non-asynchronous value. So I choose the overly verbose option for increased clarity.

Would it be feasible to make the expression await; work on its own as syntactic sugar for await undefined;?

If await null is not clear enough, I suggest adding a comment:

await null; // delay execution until the next tick

Yeah I could do that, I guess. Just thinking something that doesn't need clarification with a comment (because it would be suitably explained by most documentation) would be better.


Can you give some specific examples where you think this is necessary? I hardly ever found await null to be useful. It doesn't really delay to the next tick of the event loop, it's just a microtask, and while (true) { await null } still blocks your application. If there's a need to wait for something, one should always explicitly spell out what to wait for. Even if "wait for one microtick" sometimes works.