As of node@16
the NodeJS.Global
interface has been removed in favor of globalThis
.
You can declare new global variable in a module file as:
declare global {
var NEW_GLOBAL: string;
}
And in a non-module file (no top-level import/export) as:
declare var NEW_GLOBAL: string;
Important note: variable must be declared as var
. let
and const
variables don’t show up on globalThis
.