|
| 1 | +//// [tests/cases/compiler/enumLiteralIntersections.ts] //// |
| 2 | + |
| 3 | +=== enumLiteralIntersections.ts === |
| 4 | +enum A { |
| 5 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 6 | + |
| 7 | + One = 1, |
| 8 | +>One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 9 | + |
| 10 | + Two = "2", |
| 11 | +>Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 12 | +} |
| 13 | + |
| 14 | +const a: "2" = A.Two; |
| 15 | +>a : Symbol(a, Decl(enumLiteralIntersections.ts, 5, 5)) |
| 16 | +>A.Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 17 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 18 | +>Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 19 | + |
| 20 | +const b: 1 = A.One; |
| 21 | +>b : Symbol(b, Decl(enumLiteralIntersections.ts, 6, 5)) |
| 22 | +>A.One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 23 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 24 | +>One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 25 | + |
| 26 | +type Extant1 = A.One & 1; |
| 27 | +>Extant1 : Symbol(Extant1, Decl(enumLiteralIntersections.ts, 6, 19)) |
| 28 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 29 | +>One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 30 | + |
| 31 | +type Extant2 = A.Two & "2"; |
| 32 | +>Extant2 : Symbol(Extant2, Decl(enumLiteralIntersections.ts, 8, 25)) |
| 33 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 34 | +>Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 35 | + |
| 36 | +type ExtantAny1 = A & 1; |
| 37 | +>ExtantAny1 : Symbol(ExtantAny1, Decl(enumLiteralIntersections.ts, 9, 27)) |
| 38 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 39 | + |
| 40 | +type ExtantAny2 = A & "2"; |
| 41 | +>ExtantAny2 : Symbol(ExtantAny2, Decl(enumLiteralIntersections.ts, 10, 24)) |
| 42 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 43 | + |
| 44 | +const numericMember: Extant1 = A.One; |
| 45 | +>numericMember : Symbol(numericMember, Decl(enumLiteralIntersections.ts, 13, 5)) |
| 46 | +>Extant1 : Symbol(Extant1, Decl(enumLiteralIntersections.ts, 6, 19)) |
| 47 | +>A.One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 48 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 49 | +>One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 50 | + |
| 51 | +const stringMember: Extant2 = A.Two; |
| 52 | +>stringMember : Symbol(stringMember, Decl(enumLiteralIntersections.ts, 14, 5)) |
| 53 | +>Extant2 : Symbol(Extant2, Decl(enumLiteralIntersections.ts, 8, 25)) |
| 54 | +>A.Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 55 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 56 | +>Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 57 | + |
| 58 | +const numericEnum: ExtantAny1 = A.One; |
| 59 | +>numericEnum : Symbol(numericEnum, Decl(enumLiteralIntersections.ts, 15, 5)) |
| 60 | +>ExtantAny1 : Symbol(ExtantAny1, Decl(enumLiteralIntersections.ts, 9, 27)) |
| 61 | +>A.One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 62 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 63 | +>One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 64 | + |
| 65 | +const stringEnum: ExtantAny2 = A.Two; |
| 66 | +>stringEnum : Symbol(stringEnum, Decl(enumLiteralIntersections.ts, 16, 5)) |
| 67 | +>ExtantAny2 : Symbol(ExtantAny2, Decl(enumLiteralIntersections.ts, 10, 24)) |
| 68 | +>A.Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 69 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 70 | +>Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 71 | + |
| 72 | +const literalFirst: "2" & A.Two = A.Two; |
| 73 | +>literalFirst : Symbol(literalFirst, Decl(enumLiteralIntersections.ts, 18, 5)) |
| 74 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 75 | +>Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 76 | +>A.Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 77 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 78 | +>Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 79 | + |
| 80 | +const union: A & (0 | "2") = A.Two; |
| 81 | +>union : Symbol(union, Decl(enumLiteralIntersections.ts, 19, 5)) |
| 82 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 83 | +>A.Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 84 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 85 | +>Two : Symbol(A.Two, Decl(enumLiteralIntersections.ts, 1, 12)) |
| 86 | + |
| 87 | +// @ts-expect-error |
| 88 | +const mismatch: A & (0 | "2") = A.One; |
| 89 | +>mismatch : Symbol(mismatch, Decl(enumLiteralIntersections.ts, 21, 5)) |
| 90 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 91 | +>A.One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 92 | +>A : Symbol(A, Decl(enumLiteralIntersections.ts, 0, 0)) |
| 93 | +>One : Symbol(A.One, Decl(enumLiteralIntersections.ts, 0, 8)) |
| 94 | + |
| 95 | +// @ts-expect-error |
| 96 | +const plainString: ExtantAny2 = "2"; |
| 97 | +>plainString : Symbol(plainString, Decl(enumLiteralIntersections.ts, 23, 5)) |
| 98 | +>ExtantAny2 : Symbol(ExtantAny2, Decl(enumLiteralIntersections.ts, 10, 24)) |
| 99 | + |
0 commit comments