microsoft / microsoft/TypeScript

Add TS server command for removing all unused code in a file

オープン
#40,922 コメント 1 件 リアクション 8 件 担当者 0 名 GitHub で見る

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

Domain: LS: Quick Fixes Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Search terms

  • code action
  • source action
  • getCombinedCodeFix

Feature request

Add a new TS Server command that removes all unused code in a file. This should only perform 'safe' removals, such as:

  • Unreachable code
  • Unused imports
  • Unused declarations

We should likely not remove unused parameters. Not sure about removing unused variable since removing them can also have side effects

Use case

VS Code allows users to configure code actions that are run on save. One of the supported code actions is source.removeUnused which attempts to remove unused code in a file

On the VS Code side, we can't implement this very well since unused code often ends up overlapping with other unused code and we don't have much insight into what is "safe" to remove and what is not

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

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

はじめの一歩

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

調査の方向性

まず、既存の TS Server コマンドと issue で言及されている getCombinedCodeFix パスを読み、次に VS Code が source.removeUnused をどのように呼び出しているかを比較します。完了条件は、コマンドが安全な到達不能コード、未使用の import、未使用の宣言だけを削除し、パラメーターと副作用を持つ可能性のある変数はそのまま残すことです。

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

評価

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

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

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