microsoft / microsoft/TypeScript
Add TS server command for removing all unused code in a file
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die vorhandenen TS Server-Befehle und den im Issue erwähnten getCombinedCodeFix-Pfad zu lesen, und vergleiche anschließend, wie VS Code source.removeUnused aufruft. Fertig ist die Aufgabe, wenn ein Befehl nur sicheren unerreichbaren Code, ungenutzte Importe und ungenutzte Deklarationen entfernt und dabei Parameter sowie potenziell nebenwirkungsbehaftete Variablen unangetastet lässt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100