mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Fix self tail call return type inference in assigned anonymous functions (#58124)
This commit is contained in:
11
tests/cases/compiler/simpleRecursionWithBaseCase3.ts
Normal file
11
tests/cases/compiler/simpleRecursionWithBaseCase3.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
// @strict: true
|
||||
// @noImplicitAny: true
|
||||
// @lib: esnext
|
||||
// @noEmit: true
|
||||
|
||||
const fn1 = () => {
|
||||
if (Math.random() > 0.5) {
|
||||
return fn1()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
18
tests/cases/compiler/simpleRecursionWithBaseCase4.ts
Normal file
18
tests/cases/compiler/simpleRecursionWithBaseCase4.ts
Normal 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();
|
||||
Reference in New Issue
Block a user