TS7023
'fibonacci' 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.
Broken Code ❌
function fibonacci(n) {
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2);
}Fixed Code ✔️
To avoid the implicit typing of any for the return type, you have to add a return type annotation:
function fibonacci(n): number {
return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2);
}