microsoft / microsoft/TypeScript

typedef imports should use default exports

Offen
#36,587 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

Search Terms

checkJs typedef import

Suggestion

When the module ./core.controller has a default export defined, I would like to be able to do:

/**
 * @typedef { import("./core.controller") } Chart
 */

Instead of:

/**
 * @typedef { import("./core.controller").Chart } Chart
 */

Use Cases

My file had defined export default Chart;.

TypeScript made me add a duplicate export, which I don't want to have to add

export {
	Chart
};

This resulted in lots of extra code

It also took me an extremely long amount of time to figure out I needed to do this because the documentation did not mention this as a limitation.

Examples

Already shared in the above sections.

Checklist

My suggestion meets these guidelines:

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

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 Abschnitt zu Importtypen im TypeScript-Handbuch und den vorhandenen JSDoc-typedef-Importformen, die im Issue gezeigt werden. Verfolge, wie ein Modul mit Default-Export dargestellt und getestet wird, und bestätige anschließend, dass die kürzere Importform akzeptiert wird, ohne einen doppelten benannten Export zu erfordern, und dass die Dokumentation dieses Verhalten beschreibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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