microsoft / microsoft/TypeScript

Extract to constant in enclosing scope should optionally also replace later usage

オープン
#44,534 コメント 4 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Given this code:

	public setParts(lineNumber: number, parts: GhostTextPart[]): void {
		const foreground = this.themeService.getColorTheme().getColor(ghostTextForeground);
		let opacity: string | undefined = undefined;
		let color: string | undefined = undefined;
		if (foreground) {


			opacity = String(foreground.rgba.a);
			color = Color.Format.CSS.format(opaque(foreground))!;
		}

		const borderColor = this.themeService.getColorTheme().getColor(ghostTextBorder);
		let border: string | undefined = undefined;
		if (borderColor) {
			border = `2px dashed ${borderColor}`;
		}

I would like to factor our this.themeService.getColorTheme() and extract it into its own constant. This should include all later usages.
Since there could be side effects in between, I suggest to do it only if later occurences are also selected.

This is my current workflow and I don't feel smart doing it like that. Multicursors don't really help here.

recording

Also, it would be nice if the name of the new local is heuristically derived from the expression ((...).getFooBar(...) -> fooBar`).

I'm willing to do a PR if I get some pointers.

Let's make the editing experience in VS Code even more amazing 😉

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、TypeScript リポジトリ内で extract-to-constant リファクタリングの実装とそのテストを見つけます。次に、示されている TypeScript の例を再現し、その後、選択範囲の境界と後続の出現箇所がどのように処理されるかを追跡します。完了条件は、任意の包含スコープ抽出で、選択されている場合に限って後続の使用箇所を含められることです。ヒューリスティックな命名については別途検討します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。