Is there a way to cast a string with a typename to a type without an explicit mapping in order to use it for an angular component factory?
When there is a mapping, the process is straightforward:
public readonly typeMap: Map<string, Type<{}>> = new Map<string, Type<{}>>([
['Type1', Type1],
['Type2', Type2]
]);
The challenge arises when dealing with multiple components that need manual mapping, making it convenient to avoid using the map.
Potential solutions that I came across, but unfortunately not feasible due to minification, are:
using eval() (although considered dirty and unsafe)
using window['Type1']
Most other solutions I encountered were outdated or pointed towards mapping as the best option. Are there any innovative ideas to address this issue? Is there a possibility to accomplish this task?