microsoft / microsoft/TypeScript
moveToNewFile: move variable under cursor
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リファクタリングのエントリーポイントである moveToNewFile と、issue の比較 URL にリンクされている実装を確認します。関数名とクラス名がどのように認識されるかを追跡し、次に React コンポーネントの宣言のような変数名に何が必要かを判断します。既存の動作を維持したまま、変数名にカーソルを置いたときに Quick Fix が表示されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- developer-experience, tooling
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100