How do you explicitly set a new property on `window` in TypeScript?
@lebyy▲ 0 net votes
Problem: I setup global namespaces for my objects by explicitly setting a property on window . window.MyNamespace = window.MyNamespace || {}; TypeScript underlines MyNamespace and complains that: The property 'MyNamespace' does not exist on value of type 'window'… Fix (from the top answer): I just found the answer to this in another Stack Overflow question's answer . declare global { // Note the capital "W" interface Window { MyNamespace: any; } } window.MyNamespace = window. Basically, you need to extend the existing window interface to tell it about your new property. If you are getting an error where…