Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend tsserver interface to allow refactoring failure reporting #28410

Open
D0nGiovanni opened this issue Nov 8, 2018 · 1 comment
Open
Labels
API Relates to the public API for TypeScript Domain: TSServer Issues related to the TSServer In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@D0nGiovanni
Copy link
Contributor

D0nGiovanni commented Nov 8, 2018

Search Terms

refactoring report failure fail

Suggestion

I would like a way to report refactoring failures similar to rename fail report ("You cannot rename this element").
This change improves transparency.

Edit: This might imply changes in VS Code language server extension as well. I'm not familiar with it though.

Use Cases

This would be useful to allow refactorings to initially show the refactoring, but when invoking it, an error message should be shown, instead of just not showing the refactoring. This would be confusing to the user.

Examples

Let's say we want to inline a variable, that is not initialized. This should not be possible. But it is still useful to show the refactoring initially, since the user may be confused why the option doesn't show up.
Then, if the user wants to invoke the refactoring, they get the error message "Cannot inline uninitialized variable."

let notInitialized; // should not allow inlining, but tell user why

foo(notInitialized);

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. new expression-level syntax)
@weswigham weswigham added Suggestion An idea for TypeScript In Discussion Not yet reached consensus API Relates to the public API for TypeScript Domain: TSServer Issues related to the TSServer labels Nov 8, 2018
@D0nGiovanni D0nGiovanni changed the title Extend RefactorEditInfo interface to allow refactoring failure reporting Extend tsserver interface to allow refactoring failure reporting Nov 9, 2018
@DanielRosenwasser
Copy link
Member

There's also some related discussion over at #37895, #34930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Relates to the public API for TypeScript Domain: TSServer Issues related to the TSServer In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants