How export {} affects declare global



declare global {
  export interface Window {

export {}

I realized that export {} has an effect on redefining window module.

I saw a brief explanation that export {} makes the d.ts file a module.
However, I didn’t understand how d.ts became a module would affect the typescript.
Is there any document that I can refer to?

>Solution :

I think this official documentation of TypeScript, could help you!

Global-modifying Modules

A global-modifying module alters existing values in the global scope when they are imported. For example, there might exist a library which adds new members to String.prototype when imported. This pattern is somewhat dangerous due to the possibility of runtime conflicts, but we can still write a declaration file for it.


Leave a ReplyCancel reply