612c92d603
* Track source and target relationship stack depth seperately, only increase on change in value * Add baselines for test from #43485 * Bail on unwrapping conditional constraints on the source side when the source conditional is already known to be spooling out of control * More usage of isDeeplyNestedType to block _specifically_ conditional recursion on only one side * Negative cases of getNarrowedType that match the exact type should be filtered out, even when generic * Add test and fix for #44404 * Swap to manually specifying left and right recursion * Rename Left -> Source, Right -> Target Co-authored-by: Andrew Branch <andrew@wheream.io>
19 lines
579 B
TypeScript
19 lines
579 B
TypeScript
function f1<T, K1 extends keyof T, K2 extends keyof T[K1]>() {
|
|
let v1: Extract<T, string> = 0 as any as T; // Error
|
|
let v2: Extract<T[K1], string> = 0 as any as T[K1]; // Error
|
|
let v3: Extract<T[K1][K2], string> = 0 as any as T[K1][K2]; // No error
|
|
}
|
|
|
|
type Foo<T> = { x: Foo<T> };
|
|
type Bar<T> = { x: Bar<T[]> };
|
|
|
|
function f2<U>() {
|
|
let x: Foo<U> = 0 as any as Bar<U>; // Error, excessive stack depth
|
|
}
|
|
|
|
type Foo1<T> = { x: Foo2<T> };
|
|
type Foo2<T> = { x: Foo1<T> };
|
|
|
|
function f3<U>() {
|
|
let x: Foo1<U> = 0 as any as Bar<U>; // No error!
|
|
} |