vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.56k stars 373 forks source link

v2.0.17 Reports Errors for Multiple Event Bindings #4369

Closed aturingmachine closed 1 month ago

aturingmachine commented 1 month ago

Description

The following template (an excerpt) will be fine when vue-tsc is run using version 2.0.16, however will throw errors on 2.0.17.

<div
  @keyup.enter="handleCheck(option.value)"
  @keyup.space.prevent="handleCheck(option.value)"
>

Error:

src/components/base/base-radio-buttons.vue:14:8 - error TS1117: An object literal cannot have multiple properties with the same name.

14       @keyup.space.prevent="handleCheck(option.value)"
          ~~~~~

More Info

Our codebase is Nuxt, and we run typecheck via nuxi typecheck which runs vue-tsc via npx. Meaning this failure popped on our GitHub Actions where the npx cache misses vue-tsc and installs v2.0.17, however our local environments have v2.0.16 cached and do not report the error.

scottbedard commented 1 month ago

I'm running into this too, I was just about to open a ticket myself 🙂

https://github.com/scottbedard/vue-tsc-event-listener-type-error

This appears to be a bug though, Vue supports this syntax. Looking more at the compiled output, everything appears normal. The keydown listeners appear to be compiling correctly.

function render(_ctx, _cache, $props, $setup, $data, $options) {
  return (_openBlock(), _createElementBlock("input", {
    onKeydown: [
      $setup.onKeydown,
      _withKeys($setup.onEnter, ["enter"])
    ]
  }, null, 32 /* NEED_HYDRATION */))
}