What does ‘declare global’ accomplish inside a module file?

TypeScript Professional Medium

TypeScript Professional — Medium

What does ‘declare global’ accomplish inside a module file?

Key points

  • 'declare global' enhances the global scope from within a module
  • It adds or extends declarations on globalThis, Window, or other ambient globals
  • Useful for accessing global variables or functions within a module
  • Helps avoid importing global declarations unnecessarily

Ready to go further?

Related questions