How to config TypeScript to hide all global variables from window, only access window itself?
Example:
This code works without any problems:
function foo(length: number): void {
// Console result: A number from this scope.
console.log(length);
}
but when I remove the parameter length. The linter is still satisfied.
Because length is a global variable from window. See docs
function foo(): void {
// Console result: A number from window. (not expected in this case)
console.log(length);
}
Expected:
function foo(): void {
// Console result: undefined (or my global variable if exist)
// And in case the variable does not exist, the linter will cry as expected.
console.log(length);
}
I want to hide the window scope in global access. But I still want access the window object itself if I call it explizit like:
function foo(): void {
// This already works. But length itself without window as context should fail.
console.log(window.length);
}
Is there a tsconfig or tslint option?