microsoft / microsoft/TypeScript
Add extract to parameter refactoring for JS/TS in vscode
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando il supporto esistente per il refactoring di JavaScript/TypeScript nell’integrazione VS Code e il comportamento di esempio descritto nell’issue. Definisci come un’espressione estratta diventa un parametro e come ogni sito di chiamata esistente riceve il valore originale; il lavoro è completato quando il refactoring funziona sia per JS che per TS senza modificare il comportamento di runtime non correlato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- developer-experience, devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 32/100