Normal situation: String constants such as const TYPE1 can be used as json attribute keys, for example:
const TYPE1 = "TYPE1"
const mapper =
{
TYPE1 : param=>param
}
However, in order to facilitate the reference of a large number of type constants, I put all the type constants in a separate file and referenced them through alias. The above code becomes like this:
import * as Types from './types.js'
const mapper =
{
Types.TYPE1 : param=>param
}
Of course, this usage is wrong.
Question:
How to use Types.TYPE1 as the key of json when you want to use import * as Types from './types.js' to reference constants?