Reputation: 53
I am trying an angular project from github. I am using node version 12, angular cli 9, and updated package.json.
https://github.com/chat21/chat21-web-widget From these two files, I am getting an error while building. https://github.com/chat21/chat21-web-widget/blob/master/src/app/providers/translator.service.ts https://github.com/chat21/chat21-web-widget/blob/master/src/app/utils/globals.tsLine 31
let windowContext = window;
if (window.frameElement && window.frameElement.getAttribute('tiledesk_context') === 'parent') {
windowContext = window.parent;
}
Error Type: 'Window' is not assignable to type 'typeof globalThis'.
windowContext = window.parent;
I think this is the problem related to typescript but I am not familiar with that.
Upvotes: 4
Views: 9991
Reputation: 355
Yes, this error is expected. When you created the windowContext variable, You did not state a type, so typescript inferred that windowContext is of type "Window & typeof globalThis".
Then you tried to reassign the variable, but you reassigned it with a different type. window.parent is of type "Window". So the types don't match.
you can try this
let windowContext: any = window;
if (window.frameElement &&
window.frameElement.getAttribute('tiledesk_context') === 'parent') {
windowContext = window.parent;
}
Upvotes: 6