I use the following pattern in Javascript:
var things = {
"blue": BlueThing,
"heavy": HeavyThing,
"imaginary": ImaginaryThing
};
var my_thing = things[thing_type]();
I'm migrating the codebase to Typescript, and I can't find a way to achieve the same thing. I've defined a Thing interface, and the relevant classes. Is there a way to achieve this sort of dynamic instantiation without resorting to a big case statement?
thingsdictionary in TypeScript since types have no type.