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 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
=== tests/cases/conformance/types/intersection/intersectionsAndEmptyObjects.ts ===
// Empty object type literals are removed from intersections types
// that contain other object types
type A = { a: number };
>A : Symbol(A, Decl(intersectionsAndEmptyObjects.ts, 0, 0))
>a : Symbol(a, Decl(intersectionsAndEmptyObjects.ts, 3, 10))
type B = { b: string };
>B : Symbol(B, Decl(intersectionsAndEmptyObjects.ts, 3, 23))
>b : Symbol(b, Decl(intersectionsAndEmptyObjects.ts, 4, 10))
type C = {};
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
let x01: A & B;
>x01 : Symbol(x01, Decl(intersectionsAndEmptyObjects.ts, 7, 3))
>A : Symbol(A, Decl(intersectionsAndEmptyObjects.ts, 0, 0))
>B : Symbol(B, Decl(intersectionsAndEmptyObjects.ts, 3, 23))
let x02: A & C;
>x02 : Symbol(x02, Decl(intersectionsAndEmptyObjects.ts, 8, 3))
>A : Symbol(A, Decl(intersectionsAndEmptyObjects.ts, 0, 0))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
let x03: B & C;
>x03 : Symbol(x03, Decl(intersectionsAndEmptyObjects.ts, 9, 3))
>B : Symbol(B, Decl(intersectionsAndEmptyObjects.ts, 3, 23))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
let x04: A & B & C;
>x04 : Symbol(x04, Decl(intersectionsAndEmptyObjects.ts, 10, 3))
>A : Symbol(A, Decl(intersectionsAndEmptyObjects.ts, 0, 0))
>B : Symbol(B, Decl(intersectionsAndEmptyObjects.ts, 3, 23))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
let x05: string & C;
>x05 : Symbol(x05, Decl(intersectionsAndEmptyObjects.ts, 11, 3))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
let x06: C & string;
>x06 : Symbol(x06, Decl(intersectionsAndEmptyObjects.ts, 12, 3))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
let x07: C;
>x07 : Symbol(x07, Decl(intersectionsAndEmptyObjects.ts, 13, 3))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
let x08: C & {};
>x08 : Symbol(x08, Decl(intersectionsAndEmptyObjects.ts, 14, 3))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
let x09: {} & A & {} & B & {} & C & {};
>x09 : Symbol(x09, Decl(intersectionsAndEmptyObjects.ts, 15, 3))
>A : Symbol(A, Decl(intersectionsAndEmptyObjects.ts, 0, 0))
>B : Symbol(B, Decl(intersectionsAndEmptyObjects.ts, 3, 23))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
interface D {}
>D : Symbol(D, Decl(intersectionsAndEmptyObjects.ts, 15, 39))
interface E {}
>E : Symbol(E, Decl(intersectionsAndEmptyObjects.ts, 17, 14))
let x10: A & D;
>x10 : Symbol(x10, Decl(intersectionsAndEmptyObjects.ts, 20, 3))
>A : Symbol(A, Decl(intersectionsAndEmptyObjects.ts, 0, 0))
>D : Symbol(D, Decl(intersectionsAndEmptyObjects.ts, 15, 39))
let x11: C & D;
>x11 : Symbol(x11, Decl(intersectionsAndEmptyObjects.ts, 21, 3))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
>D : Symbol(D, Decl(intersectionsAndEmptyObjects.ts, 15, 39))
let x12: A & B & C & D;
>x12 : Symbol(x12, Decl(intersectionsAndEmptyObjects.ts, 22, 3))
>A : Symbol(A, Decl(intersectionsAndEmptyObjects.ts, 0, 0))
>B : Symbol(B, Decl(intersectionsAndEmptyObjects.ts, 3, 23))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
>D : Symbol(D, Decl(intersectionsAndEmptyObjects.ts, 15, 39))
let x13: D & E;
>x13 : Symbol(x13, Decl(intersectionsAndEmptyObjects.ts, 23, 3))
>D : Symbol(D, Decl(intersectionsAndEmptyObjects.ts, 15, 39))
>E : Symbol(E, Decl(intersectionsAndEmptyObjects.ts, 17, 14))
let x14: A & B & C & D & E;
>x14 : Symbol(x14, Decl(intersectionsAndEmptyObjects.ts, 24, 3))
>A : Symbol(A, Decl(intersectionsAndEmptyObjects.ts, 0, 0))
>B : Symbol(B, Decl(intersectionsAndEmptyObjects.ts, 3, 23))
>C : Symbol(C, Decl(intersectionsAndEmptyObjects.ts, 4, 23))
>D : Symbol(D, Decl(intersectionsAndEmptyObjects.ts, 15, 39))
>E : Symbol(E, Decl(intersectionsAndEmptyObjects.ts, 17, 14))
// Repro from #20225
type Dictionary = { [name: string]: string };
>Dictionary : Symbol(Dictionary, Decl(intersectionsAndEmptyObjects.ts, 24, 27))
>name : Symbol(name, Decl(intersectionsAndEmptyObjects.ts, 28, 21))
const intersectDictionaries = <F1 extends Dictionary, F2 extends Dictionary>(
>intersectDictionaries : Symbol(intersectDictionaries, Decl(intersectionsAndEmptyObjects.ts, 30, 5))
>F1 : Symbol(F1, Decl(intersectionsAndEmptyObjects.ts, 30, 31))
>Dictionary : Symbol(Dictionary, Decl(intersectionsAndEmptyObjects.ts, 24, 27))
>F2 : Symbol(F2, Decl(intersectionsAndEmptyObjects.ts, 30, 53))
>Dictionary : Symbol(Dictionary, Decl(intersectionsAndEmptyObjects.ts, 24, 27))
d1: F1,
>d1 : Symbol(d1, Decl(intersectionsAndEmptyObjects.ts, 30, 77))
>F1 : Symbol(F1, Decl(intersectionsAndEmptyObjects.ts, 30, 31))
d2: F2,
>d2 : Symbol(d2, Decl(intersectionsAndEmptyObjects.ts, 31, 9))
>F2 : Symbol(F2, Decl(intersectionsAndEmptyObjects.ts, 30, 53))
): F1 & F2 => Object.assign({}, d1, d2);
>F1 : Symbol(F1, Decl(intersectionsAndEmptyObjects.ts, 30, 31))
>F2 : Symbol(F2, Decl(intersectionsAndEmptyObjects.ts, 30, 53))
>Object.assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>d1 : Symbol(d1, Decl(intersectionsAndEmptyObjects.ts, 30, 77))
>d2 : Symbol(d2, Decl(intersectionsAndEmptyObjects.ts, 31, 9))
const testDictionary = <T extends Dictionary>(_value: T) => { };
>testDictionary : Symbol(testDictionary, Decl(intersectionsAndEmptyObjects.ts, 35, 5))
>T : Symbol(T, Decl(intersectionsAndEmptyObjects.ts, 35, 24))
>Dictionary : Symbol(Dictionary, Decl(intersectionsAndEmptyObjects.ts, 24, 27))
>_value : Symbol(_value, Decl(intersectionsAndEmptyObjects.ts, 35, 46))
>T : Symbol(T, Decl(intersectionsAndEmptyObjects.ts, 35, 24))
const d1 = {};
>d1 : Symbol(d1, Decl(intersectionsAndEmptyObjects.ts, 37, 5))
testDictionary(d1);
>testDictionary : Symbol(testDictionary, Decl(intersectionsAndEmptyObjects.ts, 35, 5))
>d1 : Symbol(d1, Decl(intersectionsAndEmptyObjects.ts, 37, 5))
const d2 = intersectDictionaries(d1, d1);
>d2 : Symbol(d2, Decl(intersectionsAndEmptyObjects.ts, 39, 5))
>intersectDictionaries : Symbol(intersectDictionaries, Decl(intersectionsAndEmptyObjects.ts, 30, 5))
>d1 : Symbol(d1, Decl(intersectionsAndEmptyObjects.ts, 37, 5))
>d1 : Symbol(d1, Decl(intersectionsAndEmptyObjects.ts, 37, 5))
testDictionary(d2);
>testDictionary : Symbol(testDictionary, Decl(intersectionsAndEmptyObjects.ts, 35, 5))
>d2 : Symbol(d2, Decl(intersectionsAndEmptyObjects.ts, 39, 5))
const d3 = {
>d3 : Symbol(d3, Decl(intersectionsAndEmptyObjects.ts, 42, 5))
s: '',
>s : Symbol(s, Decl(intersectionsAndEmptyObjects.ts, 42, 12))
};
testDictionary(d3);
>testDictionary : Symbol(testDictionary, Decl(intersectionsAndEmptyObjects.ts, 35, 5))
>d3 : Symbol(d3, Decl(intersectionsAndEmptyObjects.ts, 42, 5))
const d4 = intersectDictionaries(d1, d3);
>d4 : Symbol(d4, Decl(intersectionsAndEmptyObjects.ts, 46, 5))
>intersectDictionaries : Symbol(intersectDictionaries, Decl(intersectionsAndEmptyObjects.ts, 30, 5))
>d1 : Symbol(d1, Decl(intersectionsAndEmptyObjects.ts, 37, 5))
>d3 : Symbol(d3, Decl(intersectionsAndEmptyObjects.ts, 42, 5))
testDictionary(d4);
>testDictionary : Symbol(testDictionary, Decl(intersectionsAndEmptyObjects.ts, 35, 5))
>d4 : Symbol(d4, Decl(intersectionsAndEmptyObjects.ts, 46, 5))
const d5 = intersectDictionaries(d3, d1);
>d5 : Symbol(d5, Decl(intersectionsAndEmptyObjects.ts, 48, 5))
>intersectDictionaries : Symbol(intersectDictionaries, Decl(intersectionsAndEmptyObjects.ts, 30, 5))
>d3 : Symbol(d3, Decl(intersectionsAndEmptyObjects.ts, 42, 5))
>d1 : Symbol(d1, Decl(intersectionsAndEmptyObjects.ts, 37, 5))
testDictionary(d5);
>testDictionary : Symbol(testDictionary, Decl(intersectionsAndEmptyObjects.ts, 35, 5))
>d5 : Symbol(d5, Decl(intersectionsAndEmptyObjects.ts, 48, 5))
const d6 = intersectDictionaries(d3, d3);
>d6 : Symbol(d6, Decl(intersectionsAndEmptyObjects.ts, 50, 5))
>intersectDictionaries : Symbol(intersectDictionaries, Decl(intersectionsAndEmptyObjects.ts, 30, 5))
>d3 : Symbol(d3, Decl(intersectionsAndEmptyObjects.ts, 42, 5))
>d3 : Symbol(d3, Decl(intersectionsAndEmptyObjects.ts, 42, 5))
testDictionary(d6);
>testDictionary : Symbol(testDictionary, Decl(intersectionsAndEmptyObjects.ts, 35, 5))
>d6 : Symbol(d6, Decl(intersectionsAndEmptyObjects.ts, 50, 5))
// Repro from #27044
type choices<IChoiceList extends {
>choices : Symbol(choices, Decl(intersectionsAndEmptyObjects.ts, 51, 19))
>IChoiceList : Symbol(IChoiceList, Decl(intersectionsAndEmptyObjects.ts, 55, 13))
[key: string]: boolean;
>key : Symbol(key, Decl(intersectionsAndEmptyObjects.ts, 56, 5))
}> = IChoiceList & {
>IChoiceList : Symbol(IChoiceList, Decl(intersectionsAndEmptyObjects.ts, 55, 13))
shoes:boolean;
>shoes : Symbol(shoes, Decl(intersectionsAndEmptyObjects.ts, 57, 20))
food:boolean;
>food : Symbol(food, Decl(intersectionsAndEmptyObjects.ts, 58, 18))
};
type IMyChoiceList = {
>IMyChoiceList : Symbol(IMyChoiceList, Decl(intersectionsAndEmptyObjects.ts, 60, 2))
car: true
>car : Symbol(car, Decl(intersectionsAndEmptyObjects.ts, 62, 22))
};
type IUnknownChoiceList = {};
>IUnknownChoiceList : Symbol(IUnknownChoiceList, Decl(intersectionsAndEmptyObjects.ts, 64, 2))
var defaultChoices: choices<{}>;
>defaultChoices : Symbol(defaultChoices, Decl(intersectionsAndEmptyObjects.ts, 68, 3))
>choices : Symbol(choices, Decl(intersectionsAndEmptyObjects.ts, 51, 19))
var defaultChoicesAndEmpty: choices<{} & {}>;
>defaultChoicesAndEmpty : Symbol(defaultChoicesAndEmpty, Decl(intersectionsAndEmptyObjects.ts, 69, 3))
>choices : Symbol(choices, Decl(intersectionsAndEmptyObjects.ts, 51, 19))
var myChoices: choices<IMyChoiceList>;
>myChoices : Symbol(myChoices, Decl(intersectionsAndEmptyObjects.ts, 71, 3))
>choices : Symbol(choices, Decl(intersectionsAndEmptyObjects.ts, 51, 19))
>IMyChoiceList : Symbol(IMyChoiceList, Decl(intersectionsAndEmptyObjects.ts, 60, 2))
var myChoicesAndEmpty: choices<IMyChoiceList & {}>;
>myChoicesAndEmpty : Symbol(myChoicesAndEmpty, Decl(intersectionsAndEmptyObjects.ts, 72, 3))
>choices : Symbol(choices, Decl(intersectionsAndEmptyObjects.ts, 51, 19))
>IMyChoiceList : Symbol(IMyChoiceList, Decl(intersectionsAndEmptyObjects.ts, 60, 2))
var unknownChoices: choices<IUnknownChoiceList>;
>unknownChoices : Symbol(unknownChoices, Decl(intersectionsAndEmptyObjects.ts, 74, 3))
>choices : Symbol(choices, Decl(intersectionsAndEmptyObjects.ts, 51, 19))
>IUnknownChoiceList : Symbol(IUnknownChoiceList, Decl(intersectionsAndEmptyObjects.ts, 64, 2))
var unknownChoicesAndEmpty: choices<IUnknownChoiceList & {}>;
>unknownChoicesAndEmpty : Symbol(unknownChoicesAndEmpty, Decl(intersectionsAndEmptyObjects.ts, 75, 3))
>choices : Symbol(choices, Decl(intersectionsAndEmptyObjects.ts, 51, 19))
>IUnknownChoiceList : Symbol(IUnknownChoiceList, Decl(intersectionsAndEmptyObjects.ts, 64, 2))
// Repro from #38672
type Foo1 = { x: string } & { [x: number]: Foo1 };
>Foo1 : Symbol(Foo1, Decl(intersectionsAndEmptyObjects.ts, 75, 61))
>x : Symbol(x, Decl(intersectionsAndEmptyObjects.ts, 79, 13))
>x : Symbol(x, Decl(intersectionsAndEmptyObjects.ts, 79, 31))
>Foo1 : Symbol(Foo1, Decl(intersectionsAndEmptyObjects.ts, 75, 61))
type Foo2 = { x: string } & { [K in number]: Foo2 };
>Foo2 : Symbol(Foo2, Decl(intersectionsAndEmptyObjects.ts, 79, 50))
>x : Symbol(x, Decl(intersectionsAndEmptyObjects.ts, 80, 13))
>K : Symbol(K, Decl(intersectionsAndEmptyObjects.ts, 80, 31))
>Foo2 : Symbol(Foo2, Decl(intersectionsAndEmptyObjects.ts, 79, 50))
// Repro from #40239
declare function mock<M>(_: Promise<M>): {} & M;
>mock : Symbol(mock, Decl(intersectionsAndEmptyObjects.ts, 80, 52))
>M : Symbol(M, Decl(intersectionsAndEmptyObjects.ts, 84, 22))
>_ : Symbol(_, Decl(intersectionsAndEmptyObjects.ts, 84, 25))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>M : Symbol(M, Decl(intersectionsAndEmptyObjects.ts, 84, 22))
>M : Symbol(M, Decl(intersectionsAndEmptyObjects.ts, 84, 22))
mock(import('./ex'))
>mock : Symbol(mock, Decl(intersectionsAndEmptyObjects.ts, 80, 52))
>'./ex' : Symbol("tests/cases/conformance/types/intersection/ex", Decl(ex.d.ts, 0, 0))
=== tests/cases/conformance/types/intersection/ex.d.ts ===
export {}
|