microsoft / microsoft/TypeScript

Extend tsserver interface to allow refactoring failure reporting

Aperta
#28,410 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Domain: API Domain: LS: TSServer In Discussion Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

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)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando l’interfaccia di tsserver utilizzata per i refactoring e confrontala con la segnalazione esistente degli errori di rename. Verifica come l’estensione del language server di VS Code utilizza queste risposte. Il lavoro è completato quando un refactoring non riuscito restituisce un motivo che il client può visualizzare invece di nascondere silenziosamente l’errore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
api, developer-experience
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.