I`ve added
window.d.ts file with next content as proposed by many answers here
interface Window {
gameManager?: any;
}
but still getting Property 'gameManager' does not exist on type 'Window'
Do you have any idea how to simply add variable to window object without so much pain?
So, if you do, as often recommended:
declare global {
interface Window {
CONFIG: any
}
}
then you will get the TS2669 error: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations."
This is confusing, but the answer apparently is to wrap it in an external module declaration:
declare module 'my-config' {
global {
interface Window {
CONFIG: any
}
}
}
Note that you do not need to import my-config anywhere, and the name of that take module seems irrelevant. window.CONFIG will simply be available globally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With