3 ms·
> I assume it could have been made implicit Not quite. It gets ambiguous whether to wrap return or not. Example: function foo(): Promise<number> {
by ivanjermakov 2y ago
> I assume it could have been made implicit
Not quite. It gets ambiguous whether to wrap return or not. Example:
function foo(): Promise<number> {
if (...) { return Promise.resolve(5) }
...
}
but async version is:
async function foo(): Promise<number> {
if (...) { return 5 }
...
}
Although you can bake into the language one way or another.