I'm using typescript, and I want to map a string to a type so I can make instances of certain type based on a string I have.
I'm writing to node.js
For example - I get from a DB the value "range" and for that case I want to use my class "RangeFilter", but in the case of the value "size" I want to use the class "SizeFilter". They all inherit from the interface "IFilter".
So is there a way to map (create a dictionary) between the values to the type
So it could be like this
map: {key: string, value: IFilter};
Return new map["range"] //returns RangeFilter