Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 38 commits into from
Mar 3, 2025

Conversation

machty
Copy link
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
2 checks passed
@machty machty deleted the tsc-use-ls-plugins branch March 3, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
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
1 participant