typescript - Extinde modulul extern care exportă implicit


Cum pot să extind un modul care exportă implicit? De exemplu:

default-module.d.ts

declare namespace TheNamespace {
  interface TheInterface {
    prop: number
  }
}

export default TheNamespace

app.ts

import theModule from "./default-module"

declare module "./default-module" {
  interface AugmentedInterface {
    augmentedProp: number
  }
}

let theNormalVariable: theModule.TheInterface          // fine
let theAugmentedVariable: theModule.AugmentedInterface // errors

Totuși, atunci când folosești export = în loc de export default, acestea par să funcționeze bine. (așa cum s-a discutat în această problemă)

equals-module.d.ts

declare namespace TheNamespace {
  interface TheInterface {
    prop: number
  }
}

export = TheNamespace

app.ts

import theModule = require("./equals-module")

declare module "./equals-module" {
  interface AugmentedInterface {
    augmentedProp: number
  }
}

let theNormalVariable: theModule.TheInterface          // fine
let theAugmentedVariable: theModule.AugmentedInterface // fine