My understanding is that in Vue if you have a boolean reference named bar, in the templating syntax for v-bind you can pass :foo="bar" and Vue will dynamically unwrap the bar reference at runtime. In other words, I don't need to use :foo="bar.value".
I'm using the latest Vue and latest official Vue extension (which I believe used to be named "Volar") in VS Code. I have a Ref<string> that I got from a composable. I stored the composable in composableResult, and its composableResult.bar value is the reference.
Using the syntax :foo="composableResult.bar" syntax, VS Code underlines :foo in red and says:
Type 'ComputedRef' is not assignable to type 'boolean'. ts-plugin(2322)
I'm getting the idea that there is some TypeScript mismatch between the expected type and the reference, because TypeScript doesn't understand that Vue will dynamically unwrap the reference at runtime. But I thought the Vue extension was supposed to take care of those things.
Is it unavoidable that I'll need to use the :foo="composableResult.bar.value" syntax to avoid the error in VS Code? Or is there some setting or configuration I can change to allow me to use the :foo="composableResult.bar" syntax with no error?
Here's my relevant dependencies from package.json:
"dependencies": {
…
"vue": "^3.5.13"
},
"devDependencies": {
…
"typescript": "^5.9.3",
"vite-plugin-vue-devtools": "^8.0.2",
"vue-tsc": "^3.1.0",
"wxt": "^0.20.6"
}
Here's my tsconfig.json:
{
"extends": "./.wxt/tsconfig.json"
}
I'm using WXT. Here's my .wxt/tsconfig.json:
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"@": ["../src"],
"@/*": ["../src/*"],
"~": ["../src"],
"~/*": ["../src/*"],
"@@": [".."],
"@@/*": ["../*"],
"~~": [".."],
"~~/*": ["../*"]
}
},
"include": [
"../**/*",
"./wxt.d.ts"
],
"exclude": ["../.output"]
}
My vue.volar extension version is 3.1.1.
(After feedback in my other question ref loses type information when passed from a composable in the context of a `v-model`, I updated the question to clarify I was using the result of a composable without destructuring to get the ref.)
vite-plugin-vue-devtools.vue-tscavailable - try updating it withyarn add --dev vue-tsc.