TS Server: Return description of why a given refactoring cannot be applied #35098
Labels
Domain: Refactorings
e.g. extract to constant or function, rename symbol
Domain: TSServer
Issues related to the TSServer
In Discussion
Not yet reached consensus
Suggestion
An idea for TypeScript
Milestone
Follow up on #34930
Search terms
Problem
In VS Code, I often try to extract something to a function only to discover that this is not possible for the my current selection. The current UX for this is poor, since we offer no explanation of why the selection is not extractable.
Proposal
To fix this, we would like to have TS Server return a human readable message about why a refactoring cannot be applied. Client could then surface this information to users
With this proposal, TS Server would no silently longer dropping invalid refactorings like it does today and instead always return them but with an additional error message attached..
Protocol proposal
I believe this simplest approach is to add a new
errorDescription
field onApplicableRefactorInfo
:Client would be expected to not to try to resolve invalid refactorings.
To implement this in a way that won't break existing clients, we also need a way for a client to express that they can handle these invalid refactorings:
If
returnInvalidRefactorings
is not set, the TS Server should preserve its existing behavior, i.e. drop invalid refactoringsThe text was updated successfully, but these errors were encountered: