TS2669

Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.

Broken Code ❌

declare global {
  namespace NodeJS {
    interface Global {
      __coverage__: {};
    }
  }
}

You have to turn your code into a module by adding an import or export statement to your code. The easiest way to solve the problem is exporting an empty object:

Fixed Code ✔️

How to fix it using a module:

declare global {
  namespace NodeJS {
    interface Global {
      __coverage__: {};
    }
  }
}
 
export {};

Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.

Broken Code ❌

declare global {
  namespace globalThis {
    var signin: () => string[];
  }
}
 
this.signin();

Fixed Code ✔️

You can create an ambient module by using the declare module syntax:

declare module 'global' {
  namespace globalThis {
    var signin: () => string[];
  }
}
 
this.signin();