glint icon indicating copy to clipboard operation
glint copied to clipboard

Standalone .hbs-only components probably unsupportable in Glint 2

Open machty opened this issue 11 months ago • 1 comments

Classic two-file .ts + .hbs components will be (and are already partially) supported in Glint 2, but it seems likely we won't be able to support type-checking standalone .hbs-only components due to some of the constraints/assumptions within Volar.

In short:

  1. The way two-file support works is that Volar will create a VirtualCode for all of the .ts files covered by tsconfig.
  2. The VirtualCode can specify a getAssociatedFile hook, which it will use to try and find an associated .hbs file. If/once the associated file is found, it is linked and remembered in the future.
  3. When a previously-associated .hbs file is opened in the editor, Volar can perform diagnostics on it by creating the transformed-to-TS file by combining the backing .ts file with the .hbs

In short, this scheme requires a backing .ts file to exist for any TS semantic functionality for .hbs to work.

I suspect that omitting support for standalone .hbs files for the purposes of Glint 2 is probably fine; people have the option of creating backing .ts files if they really want the type-checkability, or even better they should convert to .gts template-only files.

machty avatar Mar 07 '25 10:03 machty

Sounds fine - using a ts file is currently the only way to get hbs file template-only components a signature.

NullVoxPopuli avatar Mar 07 '25 13:03 NullVoxPopuli

I guess this should be closed as it's covered by https://github.com/typed-ember/glint/pull/933

balinterdi avatar Aug 22 '25 14:08 balinterdi

I guess this should be closed as it's covered by #933

Correct, hbs support has been removed and won't be reinstated.

machty avatar Aug 22 '25 14:08 machty