microsoft / microsoft/TypeScript
moveToNewFile: move variable under cursor
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
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
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 l’entry point del refactoring moveToNewFile e l’implementazione collegata nell’URL di confronto dell’issue. Traccia il modo in cui vengono riconosciuti i nomi di funzioni e classi, quindi determina cosa è necessario per i nomi di variabili come le dichiarazioni di componenti React; il lavoro è completato quando il Quick Fix viene visualizzato con il cursore sul nome della variabile, mantenendo intatto il comportamento esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- developer-experience, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100