microsoft / microsoft/TypeScript

Feature Request: LanguageServiceHost plugin

Offen
#29,706 5 Kommentare 11 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

Search Terms

language service host compiler plugin

Refs #16607

Suggestion

Currently, TypeScript only supports proxying the language service. It would be good to have an officially supported way of being able to proxy the LanguageServiceHost as well.

Use Cases

Being able to provide a plugin that changes how the language service host behaves is often a requirement for use cases where the default behaviour of TypeScript in Visual Studio Code does not mirror the compile time behaviour when using tools that implement a language service host with TypeScript.

For example in Deno, we utilise full path names for modules, including TypeScript ones. The standard language service host disallows this (because it assumes that the module name won't end in .ts at runtime).

There are likely to be other use cases where the behaviour of the language service host differs when using other forms of TypeScript other than tsc and Visual Studio Code, where it would be useful to allow plugins to mimic that behaviour, in particular in Visual Studio Code, so that the editing experience can be more rich.

Examples

I currently have a plugin which just monkey patches the LanguageServiceHost to inject similar logic for module resolution to what is done in Deno. This is because I cannot return a proxy, like I could with the LanaguageService.

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, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der in der Issue referenzierten Anleitung „Writing a Language-Service-Plugin“ und untersuche die index.ts des Beispiel-Plugins. Vergleiche den bestehenden LanguageService-Proxy-Ansatz mit dem angeforderten Anwendungsfall für die Verwendung eines LanguageServiceHost-Proxys, einschließlich der Deno-style-Modulauflösung. Als erledigt sollte ein definierter Pfad für unterstützte Erweiterungen gelten, der Monkey-Patching vermeidet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.