Skip to content

fix(typescript-plugin): do not insert .value after a ref that the template reads unwrapped - #6402

Merged
johnsoncodehk merged 1 commit into
masterfrom
fix/value-auto-insert
Dec 1, 2026
Merged

johnsoncodehk merged 1 commit into
masterfrom
fix/value-auto-insert

Conversation

@johnsoncodehk

Copy link
Copy Markdown
Member

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) or x.value, so the identifier alone has the type of the binding, a Ref.

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.

typed in the template 3.3.11 3.3.12+ now
top-level const x = ref() / let x = ref() nothing .value nothing
v-for item that is a ref .value .value .value
ref in a property of an object (obj.count) .value .value .value

The last two rows are refs the template does not unwrap, so .value is 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

…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
@johnsoncodehk
johnsoncodehk merged commit d736046 into master Dec 1, 2026
7 checks passed
@johnsoncodehk
johnsoncodehk deleted the fix/value-auto-insert branch December 1, 2026 06:12
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.

vue.autoInsert.dotValue incorrectly inserts .value in Vue template

1 participant