microsoft / microsoft/TypeScript
moveToNewFile: move variable under cursor
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Search Terms
Move to New File
Refactor Refactoring
Suggestion
Allow selecting variable name, not only function/class name, in moveToNewFile refactoring.
Use Cases
moveToNewFile is useful for refactoring React component.
React component can be written in both function statements and arrow functions (function assigned to variable).
But current moveToNewFile implementation requires whole lines of a variable statement to be selected, while function and class can be moved by launching Quick Fix at their name.
Examples
function Component(props: Props) {
...
}
Currently, when placing cursor at anywhere in function or class name, i.e. Component in above, VSCode shows "Move to New File" menu. But if it is variable, the menu does not show up.
// Cannot refactor until selecting all lines of below statement.
// I want to refactor this by moving cursor to anywhere in "Component"
const Component: React.FC<Props> = (props: Props) => {
...
}
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.
Implementation
https://github.com/microsoft/TypeScript/compare/master...ypresto:move-var-func-to-new-file?expand=1
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, den Refactoring-Einstiegspunkt moveToNewFile und die Implementierung zu überprüfen, auf die in der Vergleichs-URL des Issues verwiesen wird. Verfolge, wie Funktions- und Klassennamen erkannt werden, und bestimme dann, was für Variablennamen wie etwa React-Komponentendeklarationen erforderlich ist; abgeschlossen ist die Aufgabe, wenn der Quick Fix angezeigt wird, während sich der Cursor auf dem Variablennamen befindet und das bestehende Verhalten intakt bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- developer-experience, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100