I just found the answer to this in another Stack Overflow question’s answer.
declare global {
interface Window { MyNamespace: any; }
}
window.MyNamespace = window.MyNamespace || {};
Basically, you need to extend the existing window
interface to tell it about your new property.
More Related Contents:
- Angular 2 @ViewChild annotation returns undefined
- TypeScript “this” scoping issue when called in jquery callback
- What is the difference between types String and string?
- Difference between Variance, Covaraince, Contravariance and Bivariance in TypeScript
- How do I prevent the error “Index signature of object type implicitly has an ‘any’ type” when compiling typescript with noImplicitAny flag enabled?
- Does Typescript support the ?. operator? (And, what’s it called?)
- How can I listen for keypress event on the whole page?
- Select based on enum in Angular2
- ‘Cannot redeclare block-scoped variable’ in unrelated files
- How to undestand relations between types any, unknown, {} and between them and other types?
- Typescript Function with Generic Return Type
- Typescript Key-Value relation preserving Object.entries type
- How to do runtime type casting in TypeScript?
- How can moment.js be imported with typescript?
- How can an object type with nested subproperties be flattened?
- Accessing properties in union types
- How can I remove a wider type from a union type without removing its subtypes in TypeScript?
- Make overProp function interface with one param
- Absolute paths (baseUrl) gives error: Cannot find module
- Checking validity of string literal union type at runtime?
- Generating typescript declaration files from javascript
- Is there an alternative to Partial to accept only fields from another type and nothing else?
- TypeScript sorting an array
- “An index signature parameter type cannot be a union type.” – what should I use instead?
- Detailed differences between type annotation `variable: type` and type assertion `expression as type` in TypeScript
- Generic and typeof T in the parameters
- How to make “handler” lookup for “dispatcher” style function be typed correctly
- How to define an interface for objects with dynamic keys?
- Types from both keys and values of object in Typescript
- Modules vs. Namespaces: What is the correct way to organize a large typescript project?