If I do window.db = db;
to expose the variable db for debugging purposes, I am told âwindow doesnât have that propertyâ.
It looked like I could declare it with Quick Fix, so I did and it added db : any to the interface Window definition in lib.dom.d.ts. I hate this because I will definitely forget to change it back later.
In TypeScript, declarations are generally merged. So you donât have to edit them directly.
typescript
This global is a kind of Module Augmentation, Global augmentation. see [Declaration Merging - TypeScript https://www.typescriptlang.org/docs/ handbook/declaration-merging.html]
typescript
The âglobalâ is added to mean âdo not define a new Window in the module in which this declaration is written, but merge it with the global Window.
This page is auto-translated from /nishio/TypeScriptă§windowă«æ°ăăăăăăăŁăè¶łă using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. Iâm very happy to spread my thought to non-Japanese readers.