Fix svelte plugin diagnostic mapping for context="module" #587
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.
Hi again 👋
After merging fix for the TS diagnostics misplacement within
context="module"
- #585 , I noticed this issue also occurs for svelte errors/warnings.Before:
After:
Changes
Again,
moduleScriptInfo
was not taken into account when creatingSvelteFragmentMapper
. Now it is.Note
In order to prevent similar errors similar to that one, I have scanned the
language-server
for references to.scriptInfo
that are not accompanied by|| doc.moduleScriptInfo
, and added the missing fallback. While I tried to do my best, these changes were only based on my limited understanding of the codebase, and I would appreciate if someone more experienced could have a look into that.To keep things clean, the first commit just solves the issue presented on the screen, and the second has the prevention measures (found via grep check, not by any observed issue). If we decide to discard the second commit, I am also fine with that.
P.S.
Going further with diagnostics for
context="module"
, I see that we are not handling correctly cases when component contains both<script>...</script>
and<script context="module">...</script>
. What are your thoughts on that? Should we wait with merging this, and try to get full handling of that as well at once, or is it fine if we go about it incrementally?