Closed
Description
π Search Terms
async recursive await
π Version & Regression Information
Latest version
β― Playground Link
π» Code
// infers type without await
async function rec1() {
if (Math.random() < 0.5) {
return rec1();
} else {
return 'hello';
}
}
// infers any with await
async function rec2() {
if (Math.random() < 0.5) {
return await rec2();
} else {
return 'hello';
}
}
π Actual behavior
infers any
with await
on self call
π Expected behavior
should infer the return type as it does without await
Additional information about the issue
To my understanding, the code has the exact same runtime behavior, so one would expect the same at compilation.
If working as intended? why?
Thanks.