vuejs / language-tools

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

Regression in vue-tsc@2.0.15: dynamic argument type incorrect #4361

Closed mdoesburg closed 4 months ago

mdoesburg commented 4 months ago

This bug was initially reported here: https://github.com/vuejs/language-tools/issues/2514

Slightly different TS error, but same result: null is not allowed to be used as a dynamic event name to remove the binding.

Reference: https://vuejs.org/guide/essentials/template-syntax.html#dynamic-argument-value-constraints

image image
johnsoncodehk commented 4 months ago

I cannot reproduce the issue, please provide minimal reproducible code or repo to help us be able to investigate it, thanks.

mdoesburg commented 4 months ago

I cannot reproduce the issue, please provide minimal reproducible code or repo to help us be able to investigate it, thanks.

Minimal reproducible code:

<script setup lang="ts">
import { computed } from 'vue';

const props = defineProps<{ toggleEnter: boolean }>();

const eventName = computed(() => (props.toggleEnter ? 'enter' : null));

function handleEvent() {
    // noop
}
</script>

<template>
    <Transition @[eventName]="handleEvent" />
</template>

Error:

image

Seems to only be an issue with event handlers on components. Doesn't give me an error on HTML elements.

johnsoncodehk commented 4 months ago

It should fixed by https://github.com/vuejs/language-tools/commit/2a3ea17c4ed37f35b6e89adc55996f92651b9a07.