microsoft / microsoft/TypeScript

Augmenting external module that is re-exported?

Offen
#18,877 5 Kommentare 13 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Needs Proposal Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

TypeScript Version: 2.5.2

Code

This can't be demonstrated with a simple 1-file code example so I made a trivial project to demo it:
https://github.com/chriseppstein/typescript_module_augmentation_bug

Instructions for how to run the demo and work around the issue are included on the README there.

When I include an interface in a node module's main index.ts file, then it is open for merging with a declare module "my_npm_module" {} but when I move that interface into a local submodule and export it in the main index.ts with a export * from "./local_module"; then the downstream consumer breaks.

Expected behavior:

It seems to me that the point of being able to export from other modules is to keep downstream consumers protected from internal refactors and maintain an existing public API. So I expect to be able to augment an interface and have it behave the same whether or not it has been re-exported.

Actual behavior:

It looks like the interface gets forked into two definitions, the downstream module sees only the interface surface that was added and the upstream module only sees the interface surface it defined.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem verlinkten typescript_module_augmentation_bug-Repository und befolge dessen README-Anweisungen, um das Problem zu reproduzieren. Vergleiche das Verhalten der Augmentierung, wenn das Interface in index.ts deklariert ist, mit dem Verhalten, wenn es aus einem lokalen Submodul re-exportiert wird. Als erledigt gilt die Aufgabe, wenn die Upstream- und Downstream-Module ein konsistentes augmentiertes Interface sehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.