Vote count: 0
I'm trying to create a Factory class in Typescript, but running into the following error.
src/ts/classes/Factory.ts(8,10): error TS7017: Element implicitly has an 'any' type because type 'Window' has no index signature.
I tried searching for this error, but didn't see anything that quite matched what I'm wanting to do.
The following is my Factory class.
/**
* @class Factory
*
* @description Returns object based on given class string
*/
class Factory {
public class(className: string): any {
return window[className];
}
}
I would rather not just suppress implicit errors in the compiler.
Any suggestions or help would be much appreciated! If this is not the best way to go about doing this, I'm definitely open to changing it as well.
asked 25 secs ago
Element implicitly has an 'any' type because type 'Window' has no index signature
Aucun commentaire:
Enregistrer un commentaire