In my Market class
, there is only one parameter: name.
class Market {
name: string
constructor(name: string) {
this.name = name
}
}
Next, I have a Markets class
that contains a static
collection of multiple markets.
class Markets {
static M1 = new Market("M1M")
static M2 = new Market("M2M")
static M3 = new Market("M3M")
}
I am curious to know if it's possible to gather all the name parameters from all markets into a single type. The resulting type would resemble something like this:
type MarketNames = "M1M" | "M2M" | "M3M"
I have heard about the keyof
operator - could this be the solution?
Thank you.