Skip to content

Reinstate glint-expect-error (and other directives) for tsc and TS Plugin using Vue's approach#799

Merged
machty merged 38 commits intomainfrom
tsc-use-ls-plugins
Mar 3, 2025
Merged

Reinstate glint-expect-error (and other directives) for tsc and TS Plugin using Vue's approach#799
machty merged 38 commits intomainfrom
tsc-use-ls-plugins

Conversation

@machty
Copy link
Copy Markdown
Contributor

@machty machty commented Feb 17, 2025

Support for @glint-expect-error was previously provided by monkeypatching the typescript-semantic Language Service plugin provided by Volar, but unfortunately:

  1. This approach isn't used by TS Plugin mode
  2. This approach isn't used by runTsc which our glint type-checking binary uses.

The solution is to move more of the expect-error (and other directive) logic into our mapping code so that when we call toVolarMappings, we can make use of the shouldReport callback to keep track of diagnostics raised within the glint-expect-error directive's area of effect. It is complicated and possibly brittle but at least it's in line with Vue, and any upstream breaking changes should be much easier to follow.

TODO

  • terminate area-of-effect for mustache statements
  • identify other terminate points and implement
  • reinstate / test glint-ignore
  • reinstate / test glint-nocheck
  • reinstate support for directives within <Element ...> body only applying to next attribute/modifier

Closes #796

Caveat: Expected Future Work

I might be actually impossible to restore exact semantics from Glint v1 directives (expect-error / ignore) do the Volar's constraints, specifically surrounding the requirement that expect-error logic be expressed as closely/statically within the transformed TS as possible. The Vue tooling maintainer acknowledges that this is much harder to pull off in Volar 2 but is necessary ultimately in order to get things working within the TS Plugin, which is the future of Volar and the only way that our classic two file (e.g. .ts + .hbs) components can/will be supported in the future.

I need to move on to other things; in the mean time, users are encouraged to try out the Alpha let me/us know whether the changes in directive behavior/semantics are too numerous to be adjusted within the codebases (or perhaps the new implementation is just plain buggy). Ultimately there will probably be some breaking changes but it's impossible for me to get a sense of scale right now.

@machty machty changed the title Experiments with Vue-ified glint-expect-error and similar directives Reinstate glint-expect-error for tsc and TS Plugin using Vue's approach Feb 19, 2025
@machty machty changed the title Reinstate glint-expect-error for tsc and TS Plugin using Vue's approach Reinstate glint-expect-error (and other directives) for tsc and TS Plugin using Vue's approach Feb 20, 2025
@machty machty merged commit 469c15e into main Mar 3, 2025
@machty machty deleted the tsc-use-ls-plugins branch March 3, 2025 17:37
@github-actions github-actions Bot mentioned this pull request Mar 23, 2025
@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Unused glint-expect-error" diagnostics sometimes span more source code text than they should

2 participants