microsoft / microsoft/TypeScript

Rename file when renaming default export

Offen
#29,294 0 Kommentare 9 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Domain: LS: Refactorings Needs Proposal Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

Currently we can use the rename symbol command and that will rename the symbol and its usages (exports, imports, usages in other files, etc.). That's a great start, but I'd love to see this feature expanded to do the following:

  • Many times a file name will coincide with the symbol being refactored. The refactor option should be available when renaming the file, so everything can be done at once.

  • In addition to the refactor changing symbol references across all files, it'd be nice to have the ability to also update comments, strings, etc. that refer to that symbol.

Code Example:

Shape.js

class Shape {}
export default Shape;

Circle.js - We reference Shape as an import, extends, inside a comment, and inside a string. They should all be refactored.

import Shape from "./Shape";

// Shape subclass
class Circle extends Shape {
  constructor() {
    super();
    console.log('A circle is a Shape.');
  }
}

export default Circle;

WebStorm Examples

screen shot 2019-01-04 at 8 36 22 pm screen shot 2019-01-04 at 8 37 02 pm

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 vorhandenen Befehl rename symbol und verfolge, wie er Exporte, Importe und Verwendungen dateiübergreifend aktualisiert. Verwende das Beispiel mit Shape.js und Circle.js als Abnahmefall: Das Umbenennen des Default-Exports sollte außerdem die passende Datei umbenennen und die gezeigten Import-, Kommentar- und String-Referenzen aktualisieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
developer-experience, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

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