Skip to content

fix(language-service): don't insert .value in template - #6273

Closed
ondrhn wants to merge 1 commit into
vuejs:masterfrom
ondrhn:fix/issue-6272-language-service-don-t-insert
Closed

ondrhn wants to merge 1 commit into
vuejs:masterfrom
ondrhn:fix/issue-6272-language-service-don-t-insert

Conversation

@ondrhn

@ondrhn ondrhn commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

With vue.autoInsert.dotValue enabled, typing the name of a ref declared in <script setup> also appends .value inside the template, where top-level refs are already unwrapped. That produces broken code and a type error. It started in v3.3.12.

provideAutoInsertSnippet in vue-autoinsert-dotvalue.ts maps the selection back to a source offset and then loops over the script blocks to decide whether the position should be skipped. When the offset lands in the template no block matches, the loop ends silently and isRefAtPosition is still consulted. That used to be harmless because template interpolations were generated as __VLS_ctx.x, whose type is already unwrapped; since #6184 generates them as direct references (__VLS_unwrap(x, ...)) the identifier is typed Ref<...> and the check returns true. The plugin now tracks whether the offset is actually inside a script block and bails out otherwise.

close #6272

The source offset mapped from the virtual script code can fall outside
the script blocks, e.g. in the template. In that case no block matched
and the loop fell through to the ref check, so bail out instead.
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for looking into #6272. It is fixed by #6402, so I am closing this one.

This pull request stops the .value auto insert for the whole template. That removes the wrong insert for a top-level ref, but also the right one for refs the template does not unwrap. With this branch built, both of these no longer get .value (3.3.11 inserted it):

<div v-for="item in list">{{ item }}</div>   <!-- const list = [ref(1), ref(2)] -->
{{ obj.count }}                              <!-- const obj = { count: ref(1) } -->

The cause was one level down: since #6184 the template reads a setup binding as __VLS_unwrap(x) or x.value, and the check still asked for the type of the identifier x alone, which is the Ref. #6402 asks for the type of the generated read, which gives the three cases their right answers; they are in its tests.

Posted for johnsoncodehk by this workflow run.

@github-actions github-actions Bot closed this Dec 1, 2026
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