|
| 1 | +//// [tests/cases/compiler/enumKeysInTypeLiteral.ts] //// |
| 2 | + |
| 3 | +=== enumKeysInTypeLiteral.ts === |
| 4 | +enum Type { |
| 5 | +>Type : Symbol(Type, Decl(enumKeysInTypeLiteral.ts, 0, 0)) |
| 6 | + |
| 7 | + Foo = 'foo', |
| 8 | +>Foo : Symbol(Type.Foo, Decl(enumKeysInTypeLiteral.ts, 0, 11)) |
| 9 | + |
| 10 | + '3x14' = '3x14' |
| 11 | +>'3x14' : Symbol(Type['3x14'], Decl(enumKeysInTypeLiteral.ts, 1, 14)) |
| 12 | +} |
| 13 | + |
| 14 | +type TypeMap = { |
| 15 | +>TypeMap : Symbol(TypeMap, Decl(enumKeysInTypeLiteral.ts, 3, 1)) |
| 16 | + |
| 17 | + [Type.Foo]: 1; |
| 18 | +>[Type.Foo] : Symbol([Type.Foo], Decl(enumKeysInTypeLiteral.ts, 5, 16)) |
| 19 | +>Type.Foo : Symbol(Type.Foo, Decl(enumKeysInTypeLiteral.ts, 0, 11)) |
| 20 | +>Type : Symbol(Type, Decl(enumKeysInTypeLiteral.ts, 0, 0)) |
| 21 | +>Foo : Symbol(Type.Foo, Decl(enumKeysInTypeLiteral.ts, 0, 11)) |
| 22 | + |
| 23 | + [Type['3x14']]: 2; |
| 24 | +>[Type['3x14']] : Symbol([Type['3x14']], Decl(enumKeysInTypeLiteral.ts, 6, 16)) |
| 25 | +>Type : Symbol(Type, Decl(enumKeysInTypeLiteral.ts, 0, 0)) |
| 26 | +>'3x14' : Symbol(Type['3x14'], Decl(enumKeysInTypeLiteral.ts, 1, 14)) |
| 27 | +} |
| 28 | + |
| 29 | +const t: TypeMap = { |
| 30 | +>t : Symbol(t, Decl(enumKeysInTypeLiteral.ts, 10, 5)) |
| 31 | +>TypeMap : Symbol(TypeMap, Decl(enumKeysInTypeLiteral.ts, 3, 1)) |
| 32 | + |
| 33 | + 'foo': 1, |
| 34 | +>'foo' : Symbol('foo', Decl(enumKeysInTypeLiteral.ts, 10, 20)) |
| 35 | + |
| 36 | + '3x14': 2 |
| 37 | +>'3x14' : Symbol('3x14', Decl(enumKeysInTypeLiteral.ts, 11, 13)) |
| 38 | + |
| 39 | +}; |
| 40 | + |
| 41 | +enum Numeric { |
| 42 | +>Numeric : Symbol(Numeric, Decl(enumKeysInTypeLiteral.ts, 13, 2)) |
| 43 | + |
| 44 | + Negative = -1, |
| 45 | +>Negative : Symbol(Numeric.Negative, Decl(enumKeysInTypeLiteral.ts, 15, 14)) |
| 46 | + |
| 47 | + Zero = 0 |
| 48 | +>Zero : Symbol(Numeric.Zero, Decl(enumKeysInTypeLiteral.ts, 16, 18)) |
| 49 | +} |
| 50 | + |
| 51 | +type NumericMap = { |
| 52 | +>NumericMap : Symbol(NumericMap, Decl(enumKeysInTypeLiteral.ts, 18, 1)) |
| 53 | + |
| 54 | + // Valid: Accessing enum member via string literal for the name |
| 55 | + [Numeric['Negative']]: number; |
| 56 | +>[Numeric['Negative']] : Symbol([Numeric['Negative']], Decl(enumKeysInTypeLiteral.ts, 20, 19), Decl(enumKeysInTypeLiteral.ts, 23, 30)) |
| 57 | +>Numeric : Symbol(Numeric, Decl(enumKeysInTypeLiteral.ts, 13, 2)) |
| 58 | +>'Negative' : Symbol(Numeric.Negative, Decl(enumKeysInTypeLiteral.ts, 15, 14)) |
| 59 | + |
| 60 | + [Numeric['Zero']]: number; |
| 61 | +>[Numeric['Zero']] : Symbol([Numeric['Zero']], Decl(enumKeysInTypeLiteral.ts, 22, 34)) |
| 62 | +>Numeric : Symbol(Numeric, Decl(enumKeysInTypeLiteral.ts, 13, 2)) |
| 63 | +>'Zero' : Symbol(Numeric.Zero, Decl(enumKeysInTypeLiteral.ts, 16, 18)) |
| 64 | + |
| 65 | + // Valid: Parenthesized access |
| 66 | + [Numeric[('Negative')]]: number; |
| 67 | +>[Numeric[('Negative')]] : Symbol([Numeric['Negative']], Decl(enumKeysInTypeLiteral.ts, 20, 19), Decl(enumKeysInTypeLiteral.ts, 23, 30)) |
| 68 | +>Numeric : Symbol(Numeric, Decl(enumKeysInTypeLiteral.ts, 13, 2)) |
| 69 | +} |
| 70 | + |
| 71 | + |
0 commit comments