typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
110 stars 51 forks source link

Discussion: Determine how to reinstate support for classic two-file components #760

Open machty opened 1 month ago

machty commented 1 month ago

Volar offers two variants for building modern type-checked language tooling:

  1. Language Server aka takeover mode (legacy) - the Language Server (e.g. Glint) spins up its own tsserver instances with Language-specific support (e.g. .gts files), and the user is encouraged to disable any built-in editor support for TypeScript files so that the Volarized LS (e.g. Glint) can/will handle all of .ts/.gts/.gjs/etc files (disabling vanilla TS is important otherwise you get duplicate diagnostic errors on .ts files). Glint also recommends this approach in the docs.

  2. TypeScript Server Plugin aka hybrid mode - this is the approach / direction taken by modern Volar: language tooling (diagnostics, auto-complete, etc) for .gts/.gjs files is provided via a TypeScript Server Plugin that runs within the editor's default/vanilla tsserver. A Language Server is still spun up to handle any non-type-specific tooling (TSPlugin + LS = "hybrid"). This approach has many benefits, including better interop with other TS plugins and avoiding the configuration awkwardness of disabling the default TS LS.

Two-File Components

Legacy LS takeover mode is basically already implemented in Glint 2 and offers excellent support for .gts/.gjs files, but unfortunately two-file components are not supported in Volar's takeover mode. Support for two-file components (whether Ember's classic component format or Angular's .ts + .html components or others) is only supported by Volar's TS Plugin API (specifically the getAssociatedScript API is only invoked when running in TS Plugin context).

How to proceed

Option 1: Push for Volar to add support for two-file components in legacy LS takeover

Johnson, I believe, has mentioned he's open to doing this, but we should make sure it's definitely necessary because I don't think anyone else is asking for it.

Option 2: Migrate Glint to newer TS Plugin API

Proposal

I think the best way forward is to: