Are there methods to modify the below piece of code in order for it to be compatible with Typescript?
public shops: string[] = [
"AShop",
"BShop",
"CShop",
];
this.shops.forEach((shop, index) => {
let instance = new window[shop](index);
this.instances.push(instance);
});
The current method is not functional with Typescript
due to the absence of window
within the scope. It cannot be compiled under these circumstances. (Even though it is effective with vanilla JS)
How can the variable name shop
within the loop be treated as an expression to generate a dynamic class from it?