Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Vue v3.4 v-bind shortand syntax #3830

Closed
cexbrayat opened this issue Dec 28, 2023 · 18 comments · Fixed by #3831
Closed

Support for Vue v3.4 v-bind shortand syntax #3830

cexbrayat opened this issue Dec 28, 2023 · 18 comments · Fixed by #3831

Comments

@cexbrayat
Copy link
Member

In Vue v3.4, it is possible to write:

<script setup>
import { ref } from 'vue'

const disabled = ref(true)
</script>

<template>
  <button :disabled>Log in</button>
</template>

But vue-tsc throws with:

error TS2322: Type '{}' is not assignable to type 'Booleanish | undefined'.

26       <button :disabled>Log in</button>
                 ~~~~~~~~~

  ../node_modules/.pnpm/@vue+runtime-dom@3.4.0-rc.3/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts:411:5
    411     disabled?: Booleanish;
            ~~~~~~~~
    The expected type comes from property 'disabled' which is declared here on type 'ButtonHTMLAttributes & ReservedProps'

See the repro on the playground

@bodograumann
Copy link

Yes please. To be honest I am a bit disappointed that this was released as a new stable feature with barely, any support in the tooling.

In addition to the problem noted above, there are more errors, when using multi-word identifiers. E.g. <button :is-disabled> is interpreted as <button v-bind:is-disabled="is-disabled"> by vue-tsc, instead of <button v-bind:is-disabled="isDisabled">.

@so1ve
Copy link
Member

so1ve commented Jan 5, 2024

<button :is-disabled> is interpreted as <button v-bind:is-disabled="is-disabled"> by vue-tsc

We haven't provided support for v-bind shorthand yet

@yoshi-pi
Copy link

Even without TypeScript, I'm getting an error message like v-bind is missing expression. vue(34). Does language-tools generate this error? If it does, could you please fix it?
スクリーンショット 2024-01-12 16 02 27

@so1ve
Copy link
Member

so1ve commented Jan 12, 2024

Because our support for v-bind shorthand has not landed yet.

@AndrewBogdanovTSS
Copy link

Hi guys, any update on this one?

@kevsommer
Copy link

Are there any new updates on this? It looks like PR #3831 should be able to solve this. Can we expect it to to be merged soon?

@ChrizzDF
Copy link

ChrizzDF commented Feb 5, 2024

@kevsommer But it's still a WIP though 😏

@so1ve
Copy link
Member

so1ve commented Feb 6, 2024

I've implemented the basic functionality, but the mappings (highlight) are inaccurate. I can pack a vsix bundle if you need.

@rocketdv
Copy link

Any update on this?

@razvaniacob
Copy link

Still nothing?

@EyalRazNadiv
Copy link

this is, literally, the only thing that prevents me from using this feature :/

@yakir-reznik
Copy link

Would really love to see this fixed. ✌️

@JoniLieh
Copy link

JoniLieh commented Mar 2, 2024

Finally working, Version 2.0 supports this, no more takeover-mode needed either, uninstall Volar :)

@liuzw2579
Copy link

support camelCase, not support kebab-case
image
image

@benkroeger
Copy link

because you can not have kebab-case variable names in JavaScript

@reneroth
Copy link

reneroth commented Mar 4, 2024

vue shorthand is meant to bind your variables with their own name... thus, in shorthand you can only use valid javascript variable names. if you want to use kebab attributes, you can not use shorthand...

It actually does work, vue converts it internally. I do agree though that it's... not optimal 🥴

@liuzw2579
Copy link

vue shorthand is meant to bind your variables with their own name... thus, in shorthand you can only use valid javascript variable names. if you want to use kebab attributes, you can not use shorthand...

It actually does work, vue converts it internally. I do agree though that it's... not optimal 🥴

eslint plugin vue rule recommend attribute hyphenation

https://eslint.vuejs.org/rules/attribute-hyphenation.html

image

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