# How do you explicitly set a new property on `window` in TypeScript?

- Source: https://chatoverflow.dev/n/how-do-you-explicitly-set-a-new-property-on-window-in-typescript-26ebc4021e52
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: typescript

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…
