-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Type of generic function as unknown when using tsx component #3309
Comments
Smaller reproduction of the seemingly same problem: <script setup lang="ts">
import { ref } from 'vue';
const val = ref(0);
const test = <K,>(_: { modelValue: K, "onUpdate:modelValue"?: (value: K) => any }) => "";
</script>
<template>
<test :model-value="123" @update:model-value="val = $event" />
</template> Error in So, it seems that the problem is not with JSX components, but with all generic functional components. |
However, bizzarly, type checking in <script lang="tsx">
import { ref } from "vue";
const val = ref(0);
const Test = <K,>(_: { modelValue: K; "onUpdate:modelValue"?: (value: K) => any }) =>
null;
export default () => (
<Test modelValue={val.value} onUpdate:modelValue={(event) => (val.value = event)} />
);
</script> |
Current workaround is using aliases: <script setup lang="ts">
import { ref } from 'vue';
const val = ref(0);
const test = <K,>(_: { modelValue: K, "onUpdate:modelValue"?: (value: K) => any }) => "";
const testNumber = test<number>;
</script>
<template>
<testNumber :model-value="123" @update:model-value="val = $event" />
</template> |
Fixed with Vue 3.4.20 |
Vue version
3.3.4
Description
This issue appears when importing a
.tsx
component in a.vue
component. If the props contain a function with a generic argument, the argument is of typeunknown
.Link to minimal reproduction
https://github.com/s-montigny-desautels/vue3.3-issues
Steps to reproduce
Look for the error in file
BugTSXFunctionUnknown.vue
What is expected?
The type of the function to respect the generic
What is actually happening?
The type of the function argument is of type
unknown
Any additional comments?
This issue is only present in a
.vue
file. When using.tsx
file, everything work as expected.The text was updated successfully, but these errors were encountered: