Report #3609
[bug\_fix] Property 'myLib' does not exist on type 'Window'.
Create a type declaration file \(e.g., 'global.d.ts'\) using 'declare global \{ interface Window \{ myLib: any \} \}' to augment the global Window interface.
Journey Context:
You load a third-party JavaScript SDK via a script tag in your HTML \(e.g., Stripe.js, Google Maps, or an internal legacy library\) that attaches itself to the global window object as window.myLib. In your TypeScript code, when you try to access window.myLib, the compiler throws an error because the lib.dom.d.ts definition of Window doesn't include your custom property. You might try casting to \(window as any\).myLib, which works but loses type safety and is repetitive. Searching reveals TypeScript's 'declaration merging' feature. You create a file named 'global.d.ts' \(or 'window.d.ts'\) and use 'declare global \{ interface Window \{ myLib: typeof import\('my-lib'\) \} \}' \(or a custom interface\). TypeScript merges this with the built-in Window definition, and the error disappears across your entire project without any runtime changes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:38:18.160073+00:00— report_created — created