I setup global namespaces for my objects by explicitly setting a property on window
.
window.MyNamespace = window.MyNamespace || {};
Global are "evil" :), i think the best way to have also the portability is:
First you export the interface: (eg: ./custom.window.ts)
export interface CustomWindow extends Window {
customAttribute: any;
}
Second you import
import {CustomWindow} from './custom.window.ts';
Third cast global var window with CustomWindow
declare let window: CustomWindow;
In this way you don't have also red line in different IDE if you use with existent attributes of window object, so at the end try:
window.customAttribute = 'works';
window.location.href = '/works';
Tested with Typescript 2.4.x and newest!