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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
|
=== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithConstructSignatures2.ts ===
// object types are identical structurally
class B {
>B : Symbol(B, Decl(objectTypesIdentityWithConstructSignatures2.ts, 0, 0))
constructor(x: number) { return null; }
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 3, 16))
}
class C<T> {
>C : Symbol(C, Decl(objectTypesIdentityWithConstructSignatures2.ts, 4, 1))
>T : Symbol(T, Decl(objectTypesIdentityWithConstructSignatures2.ts, 6, 8))
constructor(x: T) { return null; }
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 7, 16))
>T : Symbol(T, Decl(objectTypesIdentityWithConstructSignatures2.ts, 6, 8))
}
interface I {
>I : Symbol(I, Decl(objectTypesIdentityWithConstructSignatures2.ts, 8, 1))
new(x: boolean): string;
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 11, 8))
}
interface I2<T> {
>I2 : Symbol(I2, Decl(objectTypesIdentityWithConstructSignatures2.ts, 12, 1))
>T : Symbol(T, Decl(objectTypesIdentityWithConstructSignatures2.ts, 14, 13))
new(x: T): T;
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 15, 8))
>T : Symbol(T, Decl(objectTypesIdentityWithConstructSignatures2.ts, 14, 13))
>T : Symbol(T, Decl(objectTypesIdentityWithConstructSignatures2.ts, 14, 13))
}
var a: { new(x: Date): string }
>a : Symbol(a, Decl(objectTypesIdentityWithConstructSignatures2.ts, 18, 3))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 18, 13))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var b = { new(x: RegExp) { return ''; } }; // not a construct signature, function called new
>b : Symbol(b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 3))
>new : Symbol(new, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 9))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 14))
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
function foo1b(x: B);
>foo1b : Symbol(foo1b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 42), Decl(objectTypesIdentityWithConstructSignatures2.ts, 21, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 22, 21))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 21, 15))
>B : Symbol(B, Decl(objectTypesIdentityWithConstructSignatures2.ts, 0, 0))
function foo1b(x: B); // error
>foo1b : Symbol(foo1b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 42), Decl(objectTypesIdentityWithConstructSignatures2.ts, 21, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 22, 21))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 22, 15))
>B : Symbol(B, Decl(objectTypesIdentityWithConstructSignatures2.ts, 0, 0))
function foo1b(x: any) { }
>foo1b : Symbol(foo1b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 42), Decl(objectTypesIdentityWithConstructSignatures2.ts, 21, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 22, 21))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 23, 15))
function foo1c(x: C<string>);
>foo1c : Symbol(foo1c, Decl(objectTypesIdentityWithConstructSignatures2.ts, 23, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 25, 29), Decl(objectTypesIdentityWithConstructSignatures2.ts, 26, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 25, 15))
>C : Symbol(C, Decl(objectTypesIdentityWithConstructSignatures2.ts, 4, 1))
function foo1c(x: C<string>); // error
>foo1c : Symbol(foo1c, Decl(objectTypesIdentityWithConstructSignatures2.ts, 23, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 25, 29), Decl(objectTypesIdentityWithConstructSignatures2.ts, 26, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 26, 15))
>C : Symbol(C, Decl(objectTypesIdentityWithConstructSignatures2.ts, 4, 1))
function foo1c(x: any) { }
>foo1c : Symbol(foo1c, Decl(objectTypesIdentityWithConstructSignatures2.ts, 23, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 25, 29), Decl(objectTypesIdentityWithConstructSignatures2.ts, 26, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 27, 15))
function foo2(x: I);
>foo2 : Symbol(foo2, Decl(objectTypesIdentityWithConstructSignatures2.ts, 27, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 29, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 30, 20))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 29, 14))
>I : Symbol(I, Decl(objectTypesIdentityWithConstructSignatures2.ts, 8, 1))
function foo2(x: I); // error
>foo2 : Symbol(foo2, Decl(objectTypesIdentityWithConstructSignatures2.ts, 27, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 29, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 30, 20))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 30, 14))
>I : Symbol(I, Decl(objectTypesIdentityWithConstructSignatures2.ts, 8, 1))
function foo2(x: any) { }
>foo2 : Symbol(foo2, Decl(objectTypesIdentityWithConstructSignatures2.ts, 27, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 29, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 30, 20))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 31, 14))
function foo3(x: typeof a);
>foo3 : Symbol(foo3, Decl(objectTypesIdentityWithConstructSignatures2.ts, 31, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 33, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 34, 27))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 33, 14))
>a : Symbol(a, Decl(objectTypesIdentityWithConstructSignatures2.ts, 18, 3))
function foo3(x: typeof a); // error
>foo3 : Symbol(foo3, Decl(objectTypesIdentityWithConstructSignatures2.ts, 31, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 33, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 34, 27))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 34, 14))
>a : Symbol(a, Decl(objectTypesIdentityWithConstructSignatures2.ts, 18, 3))
function foo3(x: any) { }
>foo3 : Symbol(foo3, Decl(objectTypesIdentityWithConstructSignatures2.ts, 31, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 33, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 34, 27))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 35, 14))
function foo4(x: typeof b);
>foo4 : Symbol(foo4, Decl(objectTypesIdentityWithConstructSignatures2.ts, 35, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 37, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 38, 27))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 37, 14))
>b : Symbol(b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 3))
function foo4(x: typeof b); // error
>foo4 : Symbol(foo4, Decl(objectTypesIdentityWithConstructSignatures2.ts, 35, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 37, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 38, 27))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 38, 14))
>b : Symbol(b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 3))
function foo4(x: any) { }
>foo4 : Symbol(foo4, Decl(objectTypesIdentityWithConstructSignatures2.ts, 35, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 37, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 38, 27))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 39, 14))
function foo8(x: B);
>foo8 : Symbol(foo8, Decl(objectTypesIdentityWithConstructSignatures2.ts, 39, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 41, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 42, 20))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 41, 14))
>B : Symbol(B, Decl(objectTypesIdentityWithConstructSignatures2.ts, 0, 0))
function foo8(x: I); // ok
>foo8 : Symbol(foo8, Decl(objectTypesIdentityWithConstructSignatures2.ts, 39, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 41, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 42, 20))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 42, 14))
>I : Symbol(I, Decl(objectTypesIdentityWithConstructSignatures2.ts, 8, 1))
function foo8(x: any) { }
>foo8 : Symbol(foo8, Decl(objectTypesIdentityWithConstructSignatures2.ts, 39, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 41, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 42, 20))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 43, 14))
function foo9(x: B);
>foo9 : Symbol(foo9, Decl(objectTypesIdentityWithConstructSignatures2.ts, 43, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 45, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 46, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 45, 14))
>B : Symbol(B, Decl(objectTypesIdentityWithConstructSignatures2.ts, 0, 0))
function foo9(x: C<string>); // error, types are structurally equal
>foo9 : Symbol(foo9, Decl(objectTypesIdentityWithConstructSignatures2.ts, 43, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 45, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 46, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 46, 14))
>C : Symbol(C, Decl(objectTypesIdentityWithConstructSignatures2.ts, 4, 1))
function foo9(x: any) { }
>foo9 : Symbol(foo9, Decl(objectTypesIdentityWithConstructSignatures2.ts, 43, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 45, 20), Decl(objectTypesIdentityWithConstructSignatures2.ts, 46, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 47, 14))
function foo10(x: B);
>foo10 : Symbol(foo10, Decl(objectTypesIdentityWithConstructSignatures2.ts, 47, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 49, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 50, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 49, 15))
>B : Symbol(B, Decl(objectTypesIdentityWithConstructSignatures2.ts, 0, 0))
function foo10(x: typeof a); // ok
>foo10 : Symbol(foo10, Decl(objectTypesIdentityWithConstructSignatures2.ts, 47, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 49, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 50, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 50, 15))
>a : Symbol(a, Decl(objectTypesIdentityWithConstructSignatures2.ts, 18, 3))
function foo10(x: any) { }
>foo10 : Symbol(foo10, Decl(objectTypesIdentityWithConstructSignatures2.ts, 47, 25), Decl(objectTypesIdentityWithConstructSignatures2.ts, 49, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 50, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 51, 15))
function foo11(x: B);
>foo11 : Symbol(foo11, Decl(objectTypesIdentityWithConstructSignatures2.ts, 51, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 53, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 54, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 53, 15))
>B : Symbol(B, Decl(objectTypesIdentityWithConstructSignatures2.ts, 0, 0))
function foo11(x: typeof b); // ok
>foo11 : Symbol(foo11, Decl(objectTypesIdentityWithConstructSignatures2.ts, 51, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 53, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 54, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 54, 15))
>b : Symbol(b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 3))
function foo11(x: any) { }
>foo11 : Symbol(foo11, Decl(objectTypesIdentityWithConstructSignatures2.ts, 51, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 53, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 54, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 55, 15))
function foo12(x: I);
>foo12 : Symbol(foo12, Decl(objectTypesIdentityWithConstructSignatures2.ts, 55, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 57, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 58, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 57, 15))
>I : Symbol(I, Decl(objectTypesIdentityWithConstructSignatures2.ts, 8, 1))
function foo12(x: C<string>); // ok
>foo12 : Symbol(foo12, Decl(objectTypesIdentityWithConstructSignatures2.ts, 55, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 57, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 58, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 58, 15))
>C : Symbol(C, Decl(objectTypesIdentityWithConstructSignatures2.ts, 4, 1))
function foo12(x: any) { }
>foo12 : Symbol(foo12, Decl(objectTypesIdentityWithConstructSignatures2.ts, 55, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 57, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 58, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 59, 15))
function foo12b(x: I2<string>);
>foo12b : Symbol(foo12b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 59, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 61, 31), Decl(objectTypesIdentityWithConstructSignatures2.ts, 62, 30))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 61, 16))
>I2 : Symbol(I2, Decl(objectTypesIdentityWithConstructSignatures2.ts, 12, 1))
function foo12b(x: C<string>); // ok
>foo12b : Symbol(foo12b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 59, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 61, 31), Decl(objectTypesIdentityWithConstructSignatures2.ts, 62, 30))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 62, 16))
>C : Symbol(C, Decl(objectTypesIdentityWithConstructSignatures2.ts, 4, 1))
function foo12b(x: any) { }
>foo12b : Symbol(foo12b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 59, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 61, 31), Decl(objectTypesIdentityWithConstructSignatures2.ts, 62, 30))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 63, 16))
function foo13(x: I);
>foo13 : Symbol(foo13, Decl(objectTypesIdentityWithConstructSignatures2.ts, 63, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 65, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 66, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 65, 15))
>I : Symbol(I, Decl(objectTypesIdentityWithConstructSignatures2.ts, 8, 1))
function foo13(x: typeof a); // ok
>foo13 : Symbol(foo13, Decl(objectTypesIdentityWithConstructSignatures2.ts, 63, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 65, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 66, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 66, 15))
>a : Symbol(a, Decl(objectTypesIdentityWithConstructSignatures2.ts, 18, 3))
function foo13(x: any) { }
>foo13 : Symbol(foo13, Decl(objectTypesIdentityWithConstructSignatures2.ts, 63, 27), Decl(objectTypesIdentityWithConstructSignatures2.ts, 65, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 66, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 67, 15))
function foo14(x: I);
>foo14 : Symbol(foo14, Decl(objectTypesIdentityWithConstructSignatures2.ts, 67, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 69, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 70, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 69, 15))
>I : Symbol(I, Decl(objectTypesIdentityWithConstructSignatures2.ts, 8, 1))
function foo14(x: typeof b); // ok
>foo14 : Symbol(foo14, Decl(objectTypesIdentityWithConstructSignatures2.ts, 67, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 69, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 70, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 70, 15))
>b : Symbol(b, Decl(objectTypesIdentityWithConstructSignatures2.ts, 19, 3))
function foo14(x: any) { }
>foo14 : Symbol(foo14, Decl(objectTypesIdentityWithConstructSignatures2.ts, 67, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 69, 21), Decl(objectTypesIdentityWithConstructSignatures2.ts, 70, 28))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 71, 15))
function foo15(x: I2<string>);
>foo15 : Symbol(foo15, Decl(objectTypesIdentityWithConstructSignatures2.ts, 71, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 73, 30), Decl(objectTypesIdentityWithConstructSignatures2.ts, 74, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 73, 15))
>I2 : Symbol(I2, Decl(objectTypesIdentityWithConstructSignatures2.ts, 12, 1))
function foo15(x: C<number>); // ok
>foo15 : Symbol(foo15, Decl(objectTypesIdentityWithConstructSignatures2.ts, 71, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 73, 30), Decl(objectTypesIdentityWithConstructSignatures2.ts, 74, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 74, 15))
>C : Symbol(C, Decl(objectTypesIdentityWithConstructSignatures2.ts, 4, 1))
function foo15(x: any) { }
>foo15 : Symbol(foo15, Decl(objectTypesIdentityWithConstructSignatures2.ts, 71, 26), Decl(objectTypesIdentityWithConstructSignatures2.ts, 73, 30), Decl(objectTypesIdentityWithConstructSignatures2.ts, 74, 29))
>x : Symbol(x, Decl(objectTypesIdentityWithConstructSignatures2.ts, 75, 15))
|