I have defined a static property as such:
private static colorsByName: { [index: string]: MyColorClass}
but when I attempt to use for... of
from the answer listed here: TypeScript for-in statement
for(let value of MyClass.colorsByName) {
...
}
I get an error:
Type { [index: string]: MyColorClass; } is not an array type or a string type.
If I switch over to using for in
, the error goes away, but value
is typed as any
.
for(let value of MyClass.colorsByName) {
...
}
What is the actual type of value
in this case? Ideally I'd like to loop through all values in the colorsByName property, either in a pair approach, or just to get MyColorClass
types returned.
for(let value of MyClass.colorsByName) {
// value: MyColorClass
}
What are my options?
Object.keys(MyClass.colorsByName)
potentially return back,"red","black","green"
then calling the map does a projection of that enumeration? – Berglund