|
1 | 1 | === tests/cases/compiler/badInferenceLowerPriorityThanGoodInference.ts === |
| 2 | +// Repro from #13118 |
| 3 | + |
2 | 4 | interface Foo<A> { |
3 | 5 | >Foo : Symbol(Foo, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 0)) |
4 | | ->A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 14)) |
| 6 | +>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 2, 14)) |
5 | 7 |
|
6 | 8 | a: A; |
7 | | ->a : Symbol(Foo.a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 18)) |
8 | | ->A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 14)) |
| 9 | +>a : Symbol(Foo.a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 2, 18)) |
| 10 | +>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 2, 14)) |
9 | 11 |
|
10 | 12 | b: (x: A) => void; |
11 | | ->b : Symbol(Foo.b, Decl(badInferenceLowerPriorityThanGoodInference.ts, 1, 9)) |
12 | | ->x : Symbol(x, Decl(badInferenceLowerPriorityThanGoodInference.ts, 2, 8)) |
13 | | ->A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 14)) |
| 13 | +>b : Symbol(Foo.b, Decl(badInferenceLowerPriorityThanGoodInference.ts, 3, 9)) |
| 14 | +>x : Symbol(x, Decl(badInferenceLowerPriorityThanGoodInference.ts, 4, 8)) |
| 15 | +>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 2, 14)) |
14 | 16 | } |
15 | 17 |
|
16 | 18 | declare function canYouInferThis<A>(fn: () => Foo<A>): A; |
17 | | ->canYouInferThis : Symbol(canYouInferThis, Decl(badInferenceLowerPriorityThanGoodInference.ts, 3, 1)) |
18 | | ->A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 33)) |
19 | | ->fn : Symbol(fn, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 36)) |
| 19 | +>canYouInferThis : Symbol(canYouInferThis, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 1)) |
| 20 | +>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 33)) |
| 21 | +>fn : Symbol(fn, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 36)) |
20 | 22 | >Foo : Symbol(Foo, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 0)) |
21 | | ->A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 33)) |
22 | | ->A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 33)) |
| 23 | +>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 33)) |
| 24 | +>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 33)) |
23 | 25 |
|
24 | 26 | const result = canYouInferThis(() => ({ |
25 | | ->result : Symbol(result, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 5)) |
26 | | ->canYouInferThis : Symbol(canYouInferThis, Decl(badInferenceLowerPriorityThanGoodInference.ts, 3, 1)) |
| 27 | +>result : Symbol(result, Decl(badInferenceLowerPriorityThanGoodInference.ts, 9, 5)) |
| 28 | +>canYouInferThis : Symbol(canYouInferThis, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 1)) |
27 | 29 |
|
28 | 30 | a: { BLAH: 33 }, |
29 | | ->a : Symbol(a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 39)) |
30 | | ->BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 8, 8)) |
| 31 | +>a : Symbol(a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 9, 39)) |
| 32 | +>BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 10, 8)) |
31 | 33 |
|
32 | 34 | b: x => { } |
33 | | ->b : Symbol(b, Decl(badInferenceLowerPriorityThanGoodInference.ts, 8, 20)) |
34 | | ->x : Symbol(x, Decl(badInferenceLowerPriorityThanGoodInference.ts, 9, 6)) |
| 35 | +>b : Symbol(b, Decl(badInferenceLowerPriorityThanGoodInference.ts, 10, 20)) |
| 36 | +>x : Symbol(x, Decl(badInferenceLowerPriorityThanGoodInference.ts, 11, 6)) |
35 | 37 |
|
36 | 38 | })) |
37 | 39 |
|
38 | 40 | result.BLAH; |
39 | | ->result.BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 8, 8)) |
40 | | ->result : Symbol(result, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 5)) |
41 | | ->BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 8, 8)) |
| 41 | +>result.BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 10, 8)) |
| 42 | +>result : Symbol(result, Decl(badInferenceLowerPriorityThanGoodInference.ts, 9, 5)) |
| 43 | +>BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 10, 8)) |
| 44 | + |
| 45 | +// Repro from #26629 |
| 46 | + |
| 47 | +function goofus <ARGS extends any[]> (f: (...args: ARGS) => any ) {} |
| 48 | +>goofus : Symbol(goofus, Decl(badInferenceLowerPriorityThanGoodInference.ts, 14, 12)) |
| 49 | +>ARGS : Symbol(ARGS, Decl(badInferenceLowerPriorityThanGoodInference.ts, 18, 17)) |
| 50 | +>f : Symbol(f, Decl(badInferenceLowerPriorityThanGoodInference.ts, 18, 38)) |
| 51 | +>args : Symbol(args, Decl(badInferenceLowerPriorityThanGoodInference.ts, 18, 42)) |
| 52 | +>ARGS : Symbol(ARGS, Decl(badInferenceLowerPriorityThanGoodInference.ts, 18, 17)) |
| 53 | + |
| 54 | +goofus((a: string) => ({ dog() { return a; } })); |
| 55 | +>goofus : Symbol(goofus, Decl(badInferenceLowerPriorityThanGoodInference.ts, 14, 12)) |
| 56 | +>a : Symbol(a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 20, 8)) |
| 57 | +>dog : Symbol(dog, Decl(badInferenceLowerPriorityThanGoodInference.ts, 20, 24)) |
| 58 | +>a : Symbol(a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 20, 8)) |
| 59 | + |
| 60 | +goofus((a: string) => ({ dog: function() { return a; } })); |
| 61 | +>goofus : Symbol(goofus, Decl(badInferenceLowerPriorityThanGoodInference.ts, 14, 12)) |
| 62 | +>a : Symbol(a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 21, 8)) |
| 63 | +>dog : Symbol(dog, Decl(badInferenceLowerPriorityThanGoodInference.ts, 21, 24)) |
| 64 | +>a : Symbol(a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 21, 8)) |
42 | 65 |
|
0 commit comments