Skip to content

Instantly share code, notes, and snippets.

@soda92
Created November 28, 2024 09:44
Show Gist options
  • Save soda92/58fb15f93e50063013f65a00dd46f8d6 to your computer and use it in GitHub Desktop.
Save soda92/58fb15f93e50063013f65a00dd46f8d6 to your computer and use it in GitHub Desktop.
Vue `v-if` and `ref` build error: Property 'value' does not exist on type 'boolean'. Did you mean 'valueOf'?

Vue v-if and ref build error: Property 'value' does not exist on type 'boolean'. Did you mean 'valueOf'?

I've created a simple vue page with the code below: Vue link

however, when building, I've got an error: Property 'value' does not exist on type 'boolean'. Did you mean 'valueOf'?

I've tried to change "loading.value" to "loading", but the page isn't working, obviously it's not an option.

Also, the type check seems fine if I use "loading.value" in the js block. (property) Ref<boolean>.value: boolean It seems there are some magic going on in the "v-if" block. It's supposed to convert Ref<boolean> to boolean automatically. (property) loading: boolean const loading: Ref<boolean>

I use bun and vite.

  1. install bun: powershell -c "irm bun.sh/install.ps1 | iex"
  2. create project: bun create vite.
  3. select Vue+TypeScript.
  4. run bun install.
  5. Replace the code in App.vue.
  6. run bun run dev to check the web page.
  7. run bun run build.

I've tested this on npm, but I got an additional error: error TS7016: Could not find a declaration file for module './App.vue'. 'C:/src/demo-vue-error-TS2551/vite-project/src/App.vue' implicitly has an 'any' type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment