microsoft / microsoft/TypeScript

TypeScript refactoring: option to use `export default` with "Move to a new file"

Offen
#58,894 0 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.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

Among other reasons, I'd like to avoid barrel files and I find that default exports make doing so more intuitive (named exports are easily spread into a barrel file while default exports not so much).

Some files like default exports and some folks do not. I get that.

Unless there's a need to do so, I'd like VSCode to make it just as easy to use default exports as named exports. Today, TypeScript refactoring with Visual Studio Code favors named exports. This default behavior may provide some encouragement/bias to use them and not use default exports as much.

There is also a "Convert between default export and named export" refactoring which is handy but requires another step and an aware/intentional decision to use default exports.

Can "Move to a new file" be split into two options or otherwise support prompting developers to explicitly select which type of export to use while they are refactoring?

e.g.

  1. "Move to a new file as default export"
  2. "Move to a new file as named export"

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

Lesen Sie die verlinkte TypeScript-Dokumentation zum Refactoring und beginnen Sie mit dem im Issue beschriebenen Refactoring „Move to a new file“. Legen Sie den Umfang für das Anbieten expliziter Auswahlmöglichkeiten für default-export und named-export fest; abgeschlossen ist die Aufgabe, wenn Benutzer während dieses Refactorings entweder den Exportstil auswählen können.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript, vscode
Bereich
developer-experience
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.