microsoft / microsoft/TypeScript

Expose `textChanges.ChangeTracker` for public API

Aperta
#53,399 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Suggestion

I'm not sure how such requests as this one suits into TypeScript repo, but I've seen such requests earlier so decided to put another one!

Motivation: Currently it's very unclear for new developers how to contribute new code actions (refactorings / quick fixes: getEditsForRefactor / getCodeFixesAtPosition) with current plugins API. While factory API is exposed AFAICS the only way to convert nodes to actual changes is ts.createPrinter().printNode, which makes passed in formatOptions useless (just always inserting semicolons is already too annoying). I don't see a reason why don't let other developers to build their own code actions in the same way as built-in bulit.

Of course I've already seen a lot of plugins using in our days, most of them are using constructor and with along with these methods: insertNodeAt, replaceNodeRange, delete and a few others. With types exposed it would be easier to use language service methods that receive formatOptions.

🔍 Search Terms

Language Service Plugins API

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

✅ Viability 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. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

📃 Motivating Example

💻 Use Cases

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 leggendo i punti di ingresso del plugin del servizio linguistico indicati nell’issue, in particolare getEditsForRefactor e getCodeFixesAtPosition, insieme a textChanges.ChangeTracker e ai suoi metodi insertNodeAt, replaceNodeRange e delete. Determina l’API pubblica e i requisiti di compatibilità per esporre ChangeTracker, incluso come verrebbe usato formatOptions; il lavoro è completato quando la superficie supportata e l’approccio alla convalida sono chiari.

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

Valutazione

Stack tecnologico
typescript
Ambito
api, developer-experience
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.