Report #84422
[bug\_fix] Property 'myCustomProp' does not exist on type 'Window' or 'ProcessEnv' augmentation has no effect.
If the file containing the augmentation has any \`import\` or \`export\` statement, it is treated as a module. In a module, you must wrap the augmentation in \`declare global \{ ... \}\`. If the file has no imports/exports, it is a script, and \`interface Window \{ ... \}\` at the top level augments the global scope directly. Ensure the file is included in the \`tsconfig.json\` \`files\` or \`include\` array. If using a module, include \`export \{\}\` at the bottom to force module context if no imports exist, then use \`declare global\`.
Journey Context:
You need to add a custom property to the global \`window\` object \(e.g., \`window.APP\_CONFIG\`\). You create \`types/global.d.ts\` and write \`interface Window \{ APP\_CONFIG: AppConfig; \}\`. It works initially. Later, you add an import at the top of that file to reference \`AppConfig\` from another file: \`import \{ AppConfig \} from './config';\`. Suddenly, TypeScript reports that \`Property 'APP\_CONFIG' does not exist on type 'Window'\` everywhere in your codebase. You check the file; the interface is still there. You realize that adding \`import\` transformed the file from a script \(global scope\) to a module \(local scope\). In a module, \`interface Window\` shadows the global Window rather than augmenting it. You refactor to wrap the interface in \`declare global \{ interface Window \{ ... \} \}\`. You also add \`export \{\}\` to ensure it's definitely treated as a module. The augmentation starts working again. You verify that the file is included in \`tsconfig.json\`'s \`include\` array so the compiler picks it up.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:17:42.437210+00:00— report_created — created