5 ms·
I don't get it, the signature still returns `Type | Promise<Type>` how that promise doesn't spread through your code? Still, the other comment about using awai
by pmoleri 4y ago
I don't get it, the signature still returns `Type | Promise<Type>` how that promise doesn't spread through your code?
Still, the other comment about using await on plain values seems like a better option than parent comment
- tobr 4y agoc-baby’s suggestion wraps a non-promise in a promise, so I don’t see how that’s still able to return a non-promise. Awaiting plain values can only be done inside an async function, which means it returns a promise, which means you have to wait for the event loop to get the value out of there. Generally I’m not aware of any other (reasonably ergonomic) way to write a single code path that can work with both sync and async input without itself always giving async output.