Fix recursive type inference (#53396)

This commit is contained in:
Anders Hejlsberg
2023-03-21 12:53:16 -07:00
committed by GitHub
parent bace6897e2
commit 3d2c3442db
10 changed files with 143 additions and 19 deletions

View File

@@ -33,4 +33,14 @@ const foo2 = getIds([{
id: 'b',
children: []
}]
}] as const)
}] as const)
// Repro from comment in #49226
type T1<T> = [number, T1<{ x: T }>];
type T2<T> = [42, T2<{ x: T }>];
function qq<U>(x: T1<U>, y: T2<U>) {
x = y;
y = x; // Error
}

View File

@@ -95,7 +95,7 @@ declare function foo<T>(x: Box1<Box1<T>>): T;
declare let z: Box2<Box2<string>>;
foo(z); // unknown, but ideally would be string (requires unique recursion ID for each type reference)
foo(z); // string
// Intersect tuple element types