microsoft / microsoft/TypeScript
Preferred refactorings
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
Problems
-
Refactorings such as
extract functionandextract constantmay return multiple possible locations where the code could be extracted to. In many cases however, the user would just like to quick extract something to a reliable location and continue on. -
extract functionis always returned alongsideextract constant. However it is often desirable to extract to a constant instead of a function when possible.
Proposal
In the TS Server protocol, mark some refactoring as a preferred refactorings. Editors could use this information to automatically select the preferred refactoring in the list or even quick apply it without any user input (see https://github.com/Microsoft/vscode/issues/62110 for VS Code's proposal on this)
Preferred refactorings would let users set up actions such as extract constant that reliably extract to the nearest scope with a single action or keyboard shortcut. The UX behavior for this type of action:
-
If only a single
isPreferredrefactoring is returned, apply it automatically. -
If multiple preferred refactorings are returned, show a list of the preferred refactorings that the user can select from
The normal refactor context menu with full list of refactorings would continue to display the full list of refactorings.
We can start conservative with which refactorings are preferred:
- For
extract constant, extract to local const - For
extract function, extract to function at the scope of the parent function - For
extract functionin a method, extract to a method
Related to a similar proposal for quick fixes #29450
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza revisando la respuesta sobre la refactorización del protocolo de TS Server y la propuesta de quick-fix relacionada en el issue #29450. Rastrea cómo se representan los resultados de extract constant y extract function; después, define el comportamiento de refactorización preferido descrito aquí y confirma que la lista completa de refactorizaciones sigue estando disponible.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100