|
| 1 | +=== tests/cases/compiler/deepComparisons.ts === |
| 2 | +function f1<T, K1 extends keyof T, K2 extends keyof T[K1]>() { |
| 3 | +>f1 : Symbol(f1, Decl(deepComparisons.ts, 0, 0)) |
| 4 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 5 | +>K1 : Symbol(K1, Decl(deepComparisons.ts, 0, 14)) |
| 6 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 7 | +>K2 : Symbol(K2, Decl(deepComparisons.ts, 0, 34)) |
| 8 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 9 | +>K1 : Symbol(K1, Decl(deepComparisons.ts, 0, 14)) |
| 10 | + |
| 11 | + let v1: Extract<T, string> = 0 as any as T; // Error |
| 12 | +>v1 : Symbol(v1, Decl(deepComparisons.ts, 1, 7)) |
| 13 | +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) |
| 14 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 15 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 16 | + |
| 17 | + let v2: Extract<T[K1], string> = 0 as any as T[K1]; // Error |
| 18 | +>v2 : Symbol(v2, Decl(deepComparisons.ts, 2, 7)) |
| 19 | +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) |
| 20 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 21 | +>K1 : Symbol(K1, Decl(deepComparisons.ts, 0, 14)) |
| 22 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 23 | +>K1 : Symbol(K1, Decl(deepComparisons.ts, 0, 14)) |
| 24 | + |
| 25 | + let v3: Extract<T[K1][K2], string> = 0 as any as T[K1][K2]; // No error |
| 26 | +>v3 : Symbol(v3, Decl(deepComparisons.ts, 3, 7)) |
| 27 | +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) |
| 28 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 29 | +>K1 : Symbol(K1, Decl(deepComparisons.ts, 0, 14)) |
| 30 | +>K2 : Symbol(K2, Decl(deepComparisons.ts, 0, 34)) |
| 31 | +>T : Symbol(T, Decl(deepComparisons.ts, 0, 12)) |
| 32 | +>K1 : Symbol(K1, Decl(deepComparisons.ts, 0, 14)) |
| 33 | +>K2 : Symbol(K2, Decl(deepComparisons.ts, 0, 34)) |
| 34 | +} |
| 35 | + |
| 36 | +type Foo<T> = { x: Foo<T> }; |
| 37 | +>Foo : Symbol(Foo, Decl(deepComparisons.ts, 4, 1)) |
| 38 | +>T : Symbol(T, Decl(deepComparisons.ts, 6, 9)) |
| 39 | +>x : Symbol(x, Decl(deepComparisons.ts, 6, 15)) |
| 40 | +>Foo : Symbol(Foo, Decl(deepComparisons.ts, 4, 1)) |
| 41 | +>T : Symbol(T, Decl(deepComparisons.ts, 6, 9)) |
| 42 | + |
| 43 | +type Bar<T> = { x: Bar<T[]> }; |
| 44 | +>Bar : Symbol(Bar, Decl(deepComparisons.ts, 6, 28)) |
| 45 | +>T : Symbol(T, Decl(deepComparisons.ts, 7, 9)) |
| 46 | +>x : Symbol(x, Decl(deepComparisons.ts, 7, 15)) |
| 47 | +>Bar : Symbol(Bar, Decl(deepComparisons.ts, 6, 28)) |
| 48 | +>T : Symbol(T, Decl(deepComparisons.ts, 7, 9)) |
| 49 | + |
| 50 | +function f2<U>() { |
| 51 | +>f2 : Symbol(f2, Decl(deepComparisons.ts, 7, 30)) |
| 52 | +>U : Symbol(U, Decl(deepComparisons.ts, 9, 12)) |
| 53 | + |
| 54 | + let x: Foo<U> = 0 as any as Bar<U>; // Error, excessive stack depth |
| 55 | +>x : Symbol(x, Decl(deepComparisons.ts, 10, 7)) |
| 56 | +>Foo : Symbol(Foo, Decl(deepComparisons.ts, 4, 1)) |
| 57 | +>U : Symbol(U, Decl(deepComparisons.ts, 9, 12)) |
| 58 | +>Bar : Symbol(Bar, Decl(deepComparisons.ts, 6, 28)) |
| 59 | +>U : Symbol(U, Decl(deepComparisons.ts, 9, 12)) |
| 60 | +} |
| 61 | + |
| 62 | +type Foo1<T> = { x: Foo2<T> }; |
| 63 | +>Foo1 : Symbol(Foo1, Decl(deepComparisons.ts, 11, 1)) |
| 64 | +>T : Symbol(T, Decl(deepComparisons.ts, 13, 10)) |
| 65 | +>x : Symbol(x, Decl(deepComparisons.ts, 13, 16)) |
| 66 | +>Foo2 : Symbol(Foo2, Decl(deepComparisons.ts, 13, 30)) |
| 67 | +>T : Symbol(T, Decl(deepComparisons.ts, 13, 10)) |
| 68 | + |
| 69 | +type Foo2<T> = { x: Foo1<T> }; |
| 70 | +>Foo2 : Symbol(Foo2, Decl(deepComparisons.ts, 13, 30)) |
| 71 | +>T : Symbol(T, Decl(deepComparisons.ts, 14, 10)) |
| 72 | +>x : Symbol(x, Decl(deepComparisons.ts, 14, 16)) |
| 73 | +>Foo1 : Symbol(Foo1, Decl(deepComparisons.ts, 11, 1)) |
| 74 | +>T : Symbol(T, Decl(deepComparisons.ts, 14, 10)) |
| 75 | + |
| 76 | +function f3<U>() { |
| 77 | +>f3 : Symbol(f3, Decl(deepComparisons.ts, 14, 30)) |
| 78 | +>U : Symbol(U, Decl(deepComparisons.ts, 16, 12)) |
| 79 | + |
| 80 | + let x: Foo1<U> = 0 as any as Bar<U>; // No error! |
| 81 | +>x : Symbol(x, Decl(deepComparisons.ts, 17, 7)) |
| 82 | +>Foo1 : Symbol(Foo1, Decl(deepComparisons.ts, 11, 1)) |
| 83 | +>U : Symbol(U, Decl(deepComparisons.ts, 16, 12)) |
| 84 | +>Bar : Symbol(Bar, Decl(deepComparisons.ts, 6, 28)) |
| 85 | +>U : Symbol(U, Decl(deepComparisons.ts, 16, 12)) |
| 86 | +} |
0 commit comments