microsoft / microsoft/TypeScript

Expose `textChanges.ChangeTracker` for public API

Ouverte
#53,399 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Awaiting More Feedback Suggestion
Langage dominant
Go
Étoiles
111k
Forks
14.4k
Merge moyen
1 j 19 h
PR mergées (30 j)
117

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par lire les points d’entrée du plugin du service de langage nommés dans l’issue, en particulier getEditsForRefactor et getCodeFixesAtPosition, ainsi que textChanges.ChangeTracker et ses méthodes insertNodeAt, replaceNodeRange et delete. Déterminez l’API publique et les exigences de compatibilité pour exposer ChangeTracker, notamment la manière dont formatOptions serait utilisé ; le travail est terminé lorsque la surface prise en charge et l’approche de validation sont claires.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
api, developer-experience
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.