mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
283 lines
12 KiB
Plaintext
283 lines
12 KiB
Plaintext
//// [tests/cases/conformance/types/intersection/intersectionsAndEmptyObjects.ts] ////
|
|
|
|
=== 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("./ex", Decl(ex.d.ts, 0, 0))
|
|
|
|
=== ex.d.ts ===
|
|
|
|
export {}
|
|
|