Open SystemParadox opened 1 month ago
ref https://github.com/microsoft/TypeScript/issues/14306 and https://github.com/microsoft/TypeScript/issues/18433
Often "fixed" with a eslint rule no-restricted-globals
If eslint had a way to whitelist only a specific set of acceptable globals that would be ok but having to blacklisting them all with no-restricted-globals
is madness.
Far from elegant but configuring eslint once is far from madness IMO.
Adding
lib: ['DOM']
introduces 790 global variables. Many of these are deprecated and useless. Many of them have short names that can hide mistakes like a missingvar
orlet
. Some obvious offenders that absolutely result in regular bugs:event
closed
parent
screen
status
toolbar
top
length
self
history
location
origin
For this reason I have so far refrained from using
lib: ['DOM']
in my projects and prefer to access all globals viawindow.foo
instead for clarity and safety.However, this means that TS doesn't know about any of these types. Please can we make these types available so that we can at least access and use the type information without polluting the global scope with all these variables.
I'd be happy with one that just declares
document
andwindow
globals, or a types-only version that leave all globals up to us, either way I don't mind, just anything that makes the types available without all these junk globals.