1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts ===
// call signatures in derived types must have the same or fewer optional parameters as the target for assignment
interface Base {
>Base : Symbol(Base, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 0, 0))
a: (...args: number[]) => number;
>a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 2, 16))
>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 3, 8))
a2: (x: number, ...z: number[]) => number;
>a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 3, 37))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 4, 9))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 4, 19))
a3: (x: number, y?: string, ...z: number[]) => number;
>a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 4, 46))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 5, 9))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 5, 19))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 5, 31))
a4: (x?: number, y?: string, ...z: number[]) => number;
>a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 5, 58))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 6, 9))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 6, 20))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 6, 32))
}
var a: (...args: number[]) => number; // ok, same number of required params
>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3))
>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 8))
a = () => 1; // ok, same number of required params
>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3))
a = (...args: number[]) => 1; // ok, same number of required params
>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3))
>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 11, 9))
a = (...args: string[]) => 1; // error, type mismatch
>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3))
>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 12, 9))
a = (x?: number) => 1; // ok, same number of required params
>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 13, 9))
a = (x?: number, y?: number, z?: number) => 1; // ok, same number of required params
>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 14, 9))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 14, 20))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 14, 32))
a = (x: number) => 1; // ok, rest param corresponds to infinite number of params
>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 15, 9))
a = (x?: string) => 1; // error, incompatible type
>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 16, 9))
var a2: (x: number, ...z: number[]) => number;
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 9))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 19))
a2 = () => 1; // ok, fewer required params
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
a2 = (...args: number[]) => 1; // ok, fewer required params
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 21, 10))
a2 = (x?: number) => 1; // ok, fewer required params
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 22, 10))
a2 = (x: number) => 1; // ok, same number of required params
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 23, 10))
a2 = (x: number, ...args: number[]) => 1; // ok, same number of required params
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 24, 10))
>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 24, 20))
a2 = (x: number, ...args: string[]) => 1; // should be type mismatch error
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 25, 10))
>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 25, 20))
a2 = (x: number, y: number) => 1; // ok, rest param corresponds to infinite number of params
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 26, 10))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 26, 20))
a2 = (x: number, y?: number) => 1; // ok, same number of required params
>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 27, 10))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 27, 20))
var a3: (x: number, y?: string, ...z: number[]) => number;
>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 9))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 19))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 31))
a3 = () => 1; // ok, fewer required params
>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3))
a3 = (x?: number) => 1; // ok, fewer required params
>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 31, 10))
a3 = (x: number) => 1; // ok, same number of required params
>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 32, 10))
a3 = (x: number, y: string) => 1; // ok, all present params match
>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 33, 10))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 33, 20))
a3 = (x: number, y?: number, z?: number) => 1; // error
>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 34, 10))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 34, 20))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 34, 32))
a3 = (x: number, ...z: number[]) => 1; // error
>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 35, 10))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 35, 20))
a3 = (x: string, y?: string, z?: string) => 1; // error
>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 36, 10))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 36, 20))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 36, 32))
var a4: (x?: number, y?: string, ...z: number[]) => number;
>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 9))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 20))
>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 32))
a4 = () => 1; // ok, fewer required params
>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3))
a4 = (x?: number, y?: number) => 1; // error, type mismatch
>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 40, 10))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 40, 21))
a4 = (x: number) => 1; // ok, all present params match
>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 41, 10))
a4 = (x: number, y?: number) => 1; // error, second param has type mismatch
>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 42, 10))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 42, 20))
a4 = (x?: number, y?: string) => 1; // ok, same number of required params with matching types
>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 43, 10))
>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 43, 21))
a4 = (x: number, ...args: string[]) => 1; // error, rest params have type mismatch
>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 44, 10))
>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 44, 20))
|