What is the purpose of the ‘declare global’ block in TypeScript?

TypeScript Associate Hard

TypeScript Associate — Hard

What is the purpose of the ‘declare global’ block in TypeScript?

Key points

  • 'declare global' adds types to global objects from within a module
  • Helps in enhancing type safety for global objects
  • Useful for defining types for Window, globalThis, etc.

Ready to go further?

Related questions