microsoft / microsoft/TypeScript

moveToNewFile: move variable under cursor

Abierto
#32,559 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Awaiting More Feedback Domain: LS: Refactorings Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza revisando el punto de entrada de refactorización moveToNewFile y la implementación enlazada en la URL de comparación del issue. Sigue cómo se reconocen los nombres de funciones y clases y, después, determina qué se necesita para nombres de variables como las declaraciones de componentes de React; se considera terminado cuando aparece el Quick Fix con el cursor sobre el nombre de la variable, mientras el comportamiento existente permanece intacto.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, typescript
Área
developer-experience, tooling
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.