Element implicitly has an 'any' type because type 'Window' has no index signature?

后端 未结 3 1125
情歌与酒
情歌与酒 2020-12-05 22:15

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 impl

3条回答
  •  广开言路
    2020-12-05 23:11

    Another way to index on window, without having to add a declaration, is to cast it to type any:

    return (window as any)[className];
    

提交回复
热议问题