we have a javascript project and want to move to typescript.
In the current setup, we have a global object (let’s call it myGlobal
) with variables and functions that we are accessing either through windows.myGlobal.myFunction
or directly as myGlobal.varA
.
As expected, tsc would complain that windows.myGlobal
does not exist on the window object.
My guess was to write a global.d.ts
declaration file for tsc like this:
interface myGlobal {
myFunction: any
}
// Extend the Window interface
interface Window {
myGlobal: MyGlobal;
}
// Declare myGlobal as a global variable
declare let myGlobal: MyGlobal;
and even though I have
"include": [
"**/*.ts",
"**/*.js"
],
in my tsconfig, it still complaints about the same error.
Can someone help?