|
| 1 | +//// [tests/cases/compiler/reflexiveIdentityRelation.ts] //// |
| 2 | + |
| 3 | +=== reflexiveIdentityRelation.ts === |
| 4 | +namespace reflexiveIdentityRelation { |
| 5 | +>reflexiveIdentityRelation : Symbol(reflexiveIdentityRelation, Decl(reflexiveIdentityRelation.ts, 0, 0)) |
| 6 | + |
| 7 | + type Equals<A, B> = (<T>() => T extends B ? 1 : 0) extends (<T>() => T extends A ? 1 : 0) ? true : false; |
| 8 | +>Equals : Symbol(Equals, Decl(reflexiveIdentityRelation.ts, 0, 37)) |
| 9 | +>A : Symbol(A, Decl(reflexiveIdentityRelation.ts, 1, 16)) |
| 10 | +>B : Symbol(B, Decl(reflexiveIdentityRelation.ts, 1, 18)) |
| 11 | +>T : Symbol(T, Decl(reflexiveIdentityRelation.ts, 1, 26)) |
| 12 | +>T : Symbol(T, Decl(reflexiveIdentityRelation.ts, 1, 26)) |
| 13 | +>B : Symbol(B, Decl(reflexiveIdentityRelation.ts, 1, 18)) |
| 14 | +>T : Symbol(T, Decl(reflexiveIdentityRelation.ts, 1, 65)) |
| 15 | +>T : Symbol(T, Decl(reflexiveIdentityRelation.ts, 1, 65)) |
| 16 | +>A : Symbol(A, Decl(reflexiveIdentityRelation.ts, 1, 16)) |
| 17 | + |
| 18 | + type Intersection = Equals<{a: 1} & {a: 1}, {a: 1}>; // true |
| 19 | +>Intersection : Symbol(Intersection, Decl(reflexiveIdentityRelation.ts, 1, 109)) |
| 20 | +>Equals : Symbol(Equals, Decl(reflexiveIdentityRelation.ts, 0, 37)) |
| 21 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 3, 32)) |
| 22 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 3, 41)) |
| 23 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 3, 49)) |
| 24 | + |
| 25 | + type Union = Equals<{a: 1} | {a: 1}, {a: 1}>; // true |
| 26 | +>Union : Symbol(Union, Decl(reflexiveIdentityRelation.ts, 3, 56)) |
| 27 | +>Equals : Symbol(Equals, Decl(reflexiveIdentityRelation.ts, 0, 37)) |
| 28 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 4, 25)) |
| 29 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 4, 34)) |
| 30 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 4, 42)) |
| 31 | + |
| 32 | + type UnionOfIntersection = Equals<{a: 1} & {b: 2} | {a: 1} & {b: 2}, {a: 1} & {b: 2}>; // true |
| 33 | +>UnionOfIntersection : Symbol(UnionOfIntersection, Decl(reflexiveIdentityRelation.ts, 4, 49)) |
| 34 | +>Equals : Symbol(Equals, Decl(reflexiveIdentityRelation.ts, 0, 37)) |
| 35 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 5, 39)) |
| 36 | +>b : Symbol(b, Decl(reflexiveIdentityRelation.ts, 5, 48)) |
| 37 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 5, 57)) |
| 38 | +>b : Symbol(b, Decl(reflexiveIdentityRelation.ts, 5, 66)) |
| 39 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 5, 74)) |
| 40 | +>b : Symbol(b, Decl(reflexiveIdentityRelation.ts, 5, 83)) |
| 41 | + |
| 42 | + // The intersection distributes to `{a: 1} & {a: 1} | {a: 1} & {b: 2} | {b: 2} & {a: 1} | {b: 2} & {b: 2}` |
| 43 | + // which is not identical to `{a: 1} | {b: 2}` |
| 44 | + type IntersectionOfUnion = Equals<({a: 1} | {b: 2}) & ({a: 1} | {b: 2}), {a: 1} | {b: 2}>; // false |
| 45 | +>IntersectionOfUnion : Symbol(IntersectionOfUnion, Decl(reflexiveIdentityRelation.ts, 5, 90)) |
| 46 | +>Equals : Symbol(Equals, Decl(reflexiveIdentityRelation.ts, 0, 37)) |
| 47 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 9, 40)) |
| 48 | +>b : Symbol(b, Decl(reflexiveIdentityRelation.ts, 9, 49)) |
| 49 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 9, 60)) |
| 50 | +>b : Symbol(b, Decl(reflexiveIdentityRelation.ts, 9, 69)) |
| 51 | +>a : Symbol(a, Decl(reflexiveIdentityRelation.ts, 9, 78)) |
| 52 | +>b : Symbol(b, Decl(reflexiveIdentityRelation.ts, 9, 87)) |
| 53 | +} |
| 54 | + |
0 commit comments