Report #9745
[bug\_fix] Property '\_\_INITIAL\_STATE\_\_' does not exist on type 'Window & typeof globalThis'
Use the \`declare global \{ interface Window \{ \_\_INITIAL\_STATE\_\_: any; \} \}\` syntax inside the module file, or place the interface declaration in a global .d.ts file that contains no import/export statements \(making it a script, not a module\). Root cause: In a module file \(with top-level import/export\), top-level declarations are scoped to the module unless explicitly declared global.
Journey Context:
The developer is hydrating a React app from server-side rendering and needs to read window.\_\_INITIAL\_STATE\_\_. They add \`interface Window \{ \_\_INITIAL\_STATE\_\_: any; \}\` to the top of their hydrate.tsx file which has imports from React. TypeScript still reports the property doesn't exist on Window. They try moving it to a types.d.ts file, but that file accidentally contains an export statement \(making it a module\), so the augmentation doesn't apply globally. Realizing that in a module file, an interface Window declaration is local to that module, they change the code to wrap the interface in \`declare global \{ ... \}\`. They place \`declare global \{ interface Window \{ \_\_INITIAL\_STATE\_\_: ServerState; \} \}\` in their types.ts file. Now TypeScript merges this interface with the global Window declaration via declaration merging. The error disappears because the property is now known to exist on the global Window type in all modules.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:54:21.921096+00:00— report_created — created