1

I am getting the error below with window declared in our TypeScript file. How can I fix this?

const { TestFrame } = window['sisense.embed'];

Element implicitly has an 'any' type because index expression is not of type 'number'.ts(7015)

Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117
mattsmith5
  • 540
  • 4
  • 29
  • 67
  • `Window` doesn't have a known property named `"sisense.embed"`. What type of property do you expect to see there? You could merge in a property definition like [this](https://tsplay.dev/weXlEW) but I don't have enough information; could you provide a [mre] where `window['sisense.embed']` actually resolves to something other than `undefined` at runtime? – jcalz Apr 01 '22 at 19:47

1 Answers1

4

If you have defined sisense.embed on the global window object, then you could ignore the error with:

const { TestFrame } = (window as any)['sisense.embed'];

See: How do you explicitly set a new property on window in TypeScript?

Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117