refactor(core, ts-plugin): replace secondaryMapping with CustomSourceMap#363
Open
refactor(core, ts-plugin): replace secondaryMapping with CustomSourceMap#363
Conversation
🦋 Changeset detectedLatest commit: 506782f The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
cbc324a to
6b3bc59
Compare
Remove the secondaryMapping workaround for the Single-Quote Span Problem and replace it with a custom Mapper that strips outer quote characters when a direct range lookup fails. The primary mapping now covers only the inner token name, while CustomSourceMap (registered via language.mapperFactory) handles getDefinitionAtPosition spans that include the surrounding quotes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6b3bc59 to
506782f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Remove the
secondaryMappingworkaround for the Single-Quote Span Problem and replace it with a customMapperthat strips outer quote characters when a direct range lookup fails.Motivation
The real goal of this refactor is to make upcoming work easier — specifically, to let named-export mode handle token names that are not valid JavaScript identifiers (e.g.
a-4). The oldsecondaryMappingapproach produced two mapping objects per token and leaned on Volar.js's ordered-mapping fallback, which made per-token mapping logic fragile to change. By shrinking each token to a single mapping object and moving the quote-span handling intoCustomSourceMap, the mapping data becomes simple enough that subsequent work on invalid-identifier tokens can focus on codegen without fighting the mapping layer.Test plan
vp checkpasses (format, lint, type checks)vp testpasses (300 tests, 1 todo)🤖 Generated with Claude Code