export {} 如何影响 declare global

How export {} affects declare global

global.d.ts

declare global {
  export interface Window {
    ...
  }

export {}

我意识到 export {} 对重新定义 window 模块有影响。

我看到一个简短的解释,export {} 使 d.ts 文件成为一个模块。 但是,我不明白 d.ts 成为模块会如何影响打字稿。 有什么文件可以参考吗?

我觉得这个 TypeScript 的官方文档,可以帮到你!

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.

Typescript