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

Volar won't infer parameter type of @update:modelValue in recursive component #2140

Closed
rodrigocfd opened this issue Nov 24, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@rodrigocfd
Copy link

I'm writing a tree-like structure which has a recursive component. An event can be triggered and will bubble up until the component via successive emit calls.

In the example below, the argument of @update:modelValue should be automatically inferred as number. Volar, however, won't infer it and simply apply any to it, generating a TypeScript error. In the Vue application, there is no error at all – it renders correctly. So, it's a Volar issue.

Minimal reproducible code:

<script setup lang="ts">
const props = defineProps<{
  modelValue: number;
}>();

const emit = defineEmits<{
  (event: 'update:modelValue', val: number): void;
}>();
</script>

<template>
  <Foo :modelValue="props.modelValue"
    @update:modelValue="val => emit('update:modelValue', val)"
</template>

Screenshot:

sss

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants