Repository navigation
fix(typescript-plugin): do not insert .value after a ref that the template reads unwrapped - #6402
Merged
Merged
Conversation
…emplate reads unwrapped The check asked the type of the identifier, which is the `Ref` of the binding since template reads of setup bindings are generated as `__VLS_unwrap(x)` or `x.value` (#6184). It now asks the type of that read, so a top-level ref gets no `.value`, while a ref the template does not unwrap (a `v-for` item, a property of an object) still does. Fixes #6272
This was referenced Dec 1, 2026
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.
Fixes #6272. Supersedes #6273 and #6274.
What was wrong
Since 3.3.12, typing a top-level ref in the template auto-inserted
.value({{ userArr }}became{{ userArr.value }}), although the template reads it unwrapped.The check behind the auto insert asks TypeScript for the type of the identifier under the cursor. Since #6184 a template read of a setup binding is generated as
__VLS_unwrap(x)orx.value, so the identifier alone has the type of the binding, aRef.What changes
The check asks for the type of the generated read instead of the identifier. The same recognition of a template read already existed for hover; both now share it.
const x = ref()/let x = ref().valuev-foritem that is a ref.value.value.valueobj.count).value.value.valueThe last two rows are refs the template does not unwrap, so
.valueis right there; they are the cases that switching the auto insert off for the whole template would lose.Tests
packages/language-server/tests/autoInsert.spec.ts: the three rows above and<script setup>. The first two cases fail without the change.🤖 Generated with Claude Code