What I'm Trying to Do...
I'm attempting to extend the Window interface using TypeScript but also want to follow the recommended TSLint rules.
What Searches Have Produced/Suggested...
Other StackOverflow questions such as How do you explicitly set a new property on window
in TypeScript? largely recommend extending the Window
interface which seems like a preferred solution to using (window as any)
everywhere you reference Window
.
The Issue I'm Facing...
When using what seems like the ideal solution...
declare global {
interface Window {
MY_GLOBAL_VAR1: string; // reference with window.MY_GLOBAL_VAR1
MY_GLOBAL_VAR2: bool; // reference with window.MY_GLOBAL_VAR2
}
}
... the recommended TSLint throws an error because of the "no-namespace" rule.
The Plea For Help...
My goal is to not override this rule if possible. Has anyone found a solution to satisfy extending Window in a recommended TSLint-compatible way?