This code works fine at runtime using npm run dev.
But while editing this file in VSCode the following error is shown:
The same error is also emitted when doing npm run build:
src/views/Repro.vue:15:85 - error TS2551: Property 'value' does not exist on type 'boolean'. Did you mean 'valueOf'?
15 <li v-for="(item, index) in items" :key="index" :class="{'font-bold': item.isBold.value}">
~~~~~
node_modules/typescript/lib/lib.es5.d.ts:548:5
548 valueOf(): boolean;
~~~~~~~~~~~~~~~~~~~
'valueOf' is declared here.
Removing the .value accessor makes the compiler and IDE happy, but fails at runtime because this property is actually a ref (not unwrapped). It seems the editor and transpiler think this property would be unwrapped by the v-for directive, but this is definitely not happening at runtime.
What is expected?
I expect one of two things:
Either the isBold ref is indeed unwrapped by the v-for directive, and using .value is not needed
Or the isBold ref is not unwrapped, and the editor and transpiler recognize that it's a ref
What is actually happening?
See repro steps above.
Transpiler and IDE both think the .isBold property is a boolean but at runtime it is a Ref<boolean>.
Link to minimal reproduction
No response
Any additional comments?
I'm using the latest versions of both Vue, TypeScript and the VSCode extension.
Vue - Official extension or vue-tsc version
2.1.8
VSCode version
1.94.2
Vue version
3.5.12
TypeScript version
5.6.3
System Info
package.json dependencies
Steps to reproduce
Consider the following component:
This code works fine at runtime using
npm run dev
.But while editing this file in VSCode the following error is shown:
The same error is also emitted when doing
npm run build
:Removing the
.value
accessor makes the compiler and IDE happy, but fails at runtime because this property is actually a ref (not unwrapped). It seems the editor and transpiler think this property would be unwrapped by thev-for
directive, but this is definitely not happening at runtime.What is expected?
I expect one of two things:
isBold
ref is indeed unwrapped by thev-for
directive, and using.value
is not neededisBold
ref is not unwrapped, and the editor and transpiler recognize that it's a refWhat is actually happening?
See repro steps above.
Transpiler and IDE both think the
.isBold
property is aboolean
but at runtime it is aRef<boolean>
.Link to minimal reproduction
No response
Any additional comments?
I'm using the latest versions of both Vue, TypeScript and the VSCode extension.