TS7022
'window' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
Broken Code ❌
var window = window || null;{
"compilerOptions": {
"lib": ["es2017"]
}
}Fixed Code ✔️
The above error can occur when TypeScript doesn't know about the window interface. Make sure to add "dom" to your list of known runtime libraries in your compiler options:
{
"compilerOptions": {
"lib": ["dom", "es2017"]
}
}