microsoft / microsoft/TypeScript

export import in declare module

Offen
#43,159 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Suggestion

🔍 Search Terms

declare module enum export import

✅ Viability Checklist

My suggestion meets these guidelines:

  • [v] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [v] This wouldn't change the runtime behavior of existing JavaScript code
  • [v] This could be implemented without emitting different JS based on the types of the expressions
  • [v] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • [v] This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Allow export import for types and values in declare module

📃 Motivating Example

declare module './back_module' {
    /** @deprecated for backward compatible */
    export import EnumType = import('./front_module').EnumType; // Suggestion feature
}
(back_module as any).RawTypeId = front_module.RawTypeId;

// ...

import { EnumType } from './back_module';
type foobar = EnumType.Value; // it's impossible with just `type =` and `let =`
type foobar2 = OnlyForEnumType<EnumType>; // it's impossible if enum is new

💻 Use Cases

I moved EnumType to a different module but I wish to keep it backward compatible.
and back_module cannot import front_module for my situation.
So I want to declare it on the other module which combines them.

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

Beginnen Sie mit dem motivierenden Beispiel und der bestehenden Behandlung von declare module, import types und export assignments. Ermitteln Sie, wie TypeScript export import sowohl für Typen als auch für Werte darstellen würde, ohne das erzeugte JavaScript zu ändern; als abgeschlossen gilt die Aufgabe, wenn die back_module-Deklaration die gezeigte EnumType-Verwendung unterstützt und dabei die Abwärtskompatibilität bewahrt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
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.