Disregard semantic classification tokens from <template>
portions of .gts files
#873
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #835
The solution here is to classify the spans/mappings for the generated TS representing code within
<template>
regions asshouldHightlight=false
. This tells volar to NOT reverse-source-map the classification tokens generated by vanilla TS when parsing the generated TS representation of .gts files.This has the desired effect of preserving the tokens for the outer TS regions of the .gts file while ignoring the tokens for the templates. It may be desirable at some point in the future to see see how the default classifications for the template portion can be "fixed", but I don't have a sense for how difficult this might be. I suspect the reason the default classifications looking "wrong" is due to some of the constructs used for getting the type-checking aspect of Glint working correctly, e.g. in some cases we might use something like
__glintDSL.resolve('fooBar')
to represent{{this.fooBar}}
(this is not totally accurate, just an example); this might work really well for the purposes of generating useful diagnostics that can be source-mapped back to .gts, but when doing semantic classification, TS will classify this as a string argument to a function when really it's a simple property lookup onthis
.