@@ -52,40 +52,54 @@ type ExtractParameters<T> = "parameters" extends keyof T
52
52
53
53
: {};
54
54
55
+ // Original example, but with inverted variance
55
56
type Q2<T> = number extends T ? (cb: (n: number) => void) => void : never;
56
57
>Q2 : Symbol(Q2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 17, 7))
57
- >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 19 , 8))
58
- >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 19 , 8))
59
- >cb : Symbol(cb, Decl(callOfConditionalTypeWithConcreteBranches.ts, 19 , 33))
60
- >n : Symbol(n, Decl(callOfConditionalTypeWithConcreteBranches.ts, 19 , 38))
58
+ >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 8))
59
+ >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 8))
60
+ >cb : Symbol(cb, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 33))
61
+ >n : Symbol(n, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 38))
61
62
62
63
function fn2<T>(arg: Q2<T>) {
63
- >fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 19 , 74))
64
- >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 13))
65
- >arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 16))
64
+ >fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 74))
65
+ >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21 , 13))
66
+ >arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21 , 16))
66
67
>Q2 : Symbol(Q2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 17, 7))
67
- >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 13))
68
+ >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21 , 13))
68
69
69
70
function useT(_arg: T): void {}
70
- >useT : Symbol(useT, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 29))
71
- >_arg : Symbol(_arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21 , 16))
72
- >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 13))
71
+ >useT : Symbol(useT, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21 , 29))
72
+ >_arg : Symbol(_arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 22 , 16))
73
+ >T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21 , 13))
73
74
74
75
// Expected: OK
75
76
arg(arg => useT(arg));
76
- >arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 16))
77
- >arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 23 , 6))
78
- >useT : Symbol(useT, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 29))
79
- >arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 23 , 6))
77
+ >arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21 , 16))
78
+ >arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 24 , 6))
79
+ >useT : Symbol(useT, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21 , 29))
80
+ >arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 24 , 6))
80
81
}
81
82
// Legal invocations are not problematic
82
83
fn2<string | number>(m => m(42));
83
- >fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 19 , 74))
84
- >m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 26 , 21))
85
- >m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 26 , 21))
84
+ >fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20 , 74))
85
+ >m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 27 , 21))
86
+ >m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 27 , 21))
86
87
87
88
fn2<number>(m => m(42));
88
- >fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 19, 74))
89
- >m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 27, 12))
90
- >m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 27, 12))
89
+ >fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 74))
90
+ >m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 12))
91
+ >m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 12))
92
+
93
+ // webidl-conversions example where substituion must occur, despite contravariance of the position
94
+ // due to the invariant usage in `Parameters`
95
+
96
+ type X<V> = V extends (...args: any[]) => any ? (...args: Parameters<V>) => void : Function;
97
+ >X : Symbol(X, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 24))
98
+ >V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7))
99
+ >V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7))
100
+ >args : Symbol(args, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 23))
101
+ >args : Symbol(args, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 49))
102
+ >Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --))
103
+ >V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7))
104
+ >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
91
105
0 commit comments