Reputation:
I've expected TheWall to be 0 within the TileSpecs literal, but it doesnt. Why and how to fix this?
enum Tile = {WALL, BORDER}
const TheWall: Tile = Tile.WALL;
console.log(TheWall) // Prints 0
let TileSpecs = {
TheWall: {prop: 'value'}
}
console.log(TileSpecs) // Prints TheWall: {...}
Upvotes: 0
Views: 1162
Reputation: 312005
To use your TheWall
constant as a property name, you need to use computed property name syntax:
let TileSpecs = {
[TheWall]: {prop: 'value'}
}
Upvotes: 3