Closed
Description
🔎 Search Terms
recursive function arrow function
🕗 Version & Regression Information
- This is a crash
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
💻 Code
// const foo: () => any
const foo = () => {
if (Math.random() > 0.5) {
return foo()
}
return 0
}
// function bar(): number
function bar() {
if (Math.random() > 0.5) {
return bar()
}
return 0
}
🙁 Actual behavior
const foo: () => any
'foo' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
🙂 Expected behavior
The inference should be const foo: () => number, even this inference is happened before the arrow function assign to foo
Additional information about the issue
No response