How to add properties to existing objects in TypeScript

declare global {
    interface Window { MyNamespace: any; }
}

window.MyNamespace = window.MyNamespace || {};

The above adds the MyNamespace property to window, by declaring that window (which implements/inherits from Window), has a property named MyNamespace.

See also: What does “variable = variable || {}” mean in JavaScript.