Fix self tail call return type inference in assigned anonymous functions (#58124)

This commit is contained in:
Andrew Branch
2024-04-10 12:51:34 -07:00
committed by GitHub
parent 30095a225c
commit 2b038ff64a
9 changed files with 214 additions and 11 deletions

View File

@@ -0,0 +1,11 @@
// @strict: true
// @noImplicitAny: true
// @lib: esnext
// @noEmit: true
const fn1 = () => {
if (Math.random() > 0.5) {
return fn1()
}
return 0
}

View File

@@ -0,0 +1,18 @@
// @checkJs: true
// @noEmit: true
// @strict: false
var fn2 = function(name) {
fn2 = compose(this, 0, 1)
return fn2(name)
function compose(child, level, find) {
if (child === find) {
return level
}
return compose(child, level + 1, find)
}
}
var d = fn2(1); // d: any
d.redefined();