microsoft / microsoft/TypeScript
Extract to function in upper scope
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
We have Extract to function in module scope and Extract to inner function in function xxx(which is Extract to function in current scope), we should also have Extract to function in upper scope. With it, we can:
const g = 'g';
export function A() {
const a_local = 'a';
return function B() {
const b_local = 'b';
return function C() {
const c_local = 'c';
// the bottom will be extracted to function upper scope
console.log(g, a_local, b_local, c_local);
// the above will be extracted to function upper scope
}
}
}
After the extraction, code will be:
const g = 'g';
export function A() {
const a_local = 'a';
return function B() {
const b_local = 'b';
function newFunction(c_local: string) {
console.log(g, a_local, b_local, c_local);
}
return function C() {
const c_local = 'c';
newFunction(c_local);
}
}
}
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 Implementierungen und Tests für „Extract to function in module scope“ und „Extract to function in current scope“ zu finden. Erweitere das bestehende Refactoring-Verhalten so, dass die Extraktion auf den übergeordneten Funktions-Scope abzielen kann, während Variablen aus tieferen Scopes als Parameter übergeben werden, und füge eine Abdeckung hinzu, die dem TypeScript-Beispiel entspricht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- 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
- 38/100