I'm attempting to develop a Factory class in Typescript, however I've encountered the following issue:
src/ts/classes/Factory.ts(8,10): error TS7017: Element implicitly has an 'any' type because type 'Window' has no index signature.
I have searched for a solution to this error, but haven't found anything that directly addresses my specific situation.
Below is the code for my Factory class.
/**
* @class Factory
*
* @description Returns object based on given class string
*/
class Factory {
public getClass(className: string): any {
return window[className];
}
}
I prefer not to simply ignore implicit errors in the compiler.
Any advice or assistance on resolving this issue would be greatly appreciated! If there's a better approach to achieving the desired result, I am open to making adjustments as well.