microsoft / microsoft/TypeScript
Add extract to parameter refactoring for JS/TS in vscode
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Search Terms
Suggestion
Add a refactoring to extract to parameter for JS/TS
e.g.
for
const fangler = () => {
return {
someProperty: [
"a", "b"
]
}
}
the extract to parameter refactoring would change to
const fangler = (secondItem) => {
return {
someProperty: [
"a", secondItem
]
}
}
and populate each existing call site with the extracted value (in this example "b")
Use Cases
It is a common refactoring when you discover that a previously fixed value should instead be provided by a caller
Examples
e.g. in the case where I went looking for it code in a Lambda function that created a fixed header had to start providing a varying value depending on context and the easiest refactoring was to extract the currently fixed value as a parameter so that the callers that would vary it could do without breaking other callers
see https://twitter.com/mattbierner/status/1234920525543002113
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
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, die vorhandene Unterstützung für das Refactoring von JavaScript/TypeScript in der VS Code-Integration sowie das im Issue beschriebene Beispielverhalten zu prüfen. Definiere, wie ein extrahierter Ausdruck zu einem Parameter wird und wie jede vorhandene Aufrufstelle den ursprünglichen Wert erhält; abgeschlossen ist die Aufgabe, wenn das Refactoring sowohl für JS als auch für TS funktioniert, ohne das Laufzeitverhalten an anderer Stelle zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- developer-experience, devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 32/100