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
TS Error on props when using Generic SFC #3405
Comments
Seems like this might be a duplicate of #3204? |
I'm having the same issue. I just tried generics for the first time. Oddly enough, working: <script lang="ts" setup generic="T extends ListItem">
export interface ListItem {
id: string;
title: string;
}
const props = defineProps<{
items: T[];
}>();
</script>
<template>
<div>{{ items[0].title }}</div>
</template> But... not working. All I did was change <script lang="ts" setup generic="T extends ListItem">
export interface ListItem {
id: string;
title: string;
}
const props = defineProps<{
item: T;
}>();
</script>
<template>
<ul>
{{ item.title }}</li>
</ul>
</template> |
I also use vue in version 3.3.4 and 1.8.10 version of volar. I try to create a generic component but I receive an error message: <template>
<p>{{ animal.name }}</p>
</template>
<script setup lang="ts" generic="T extends Animal">
export interface Animal {
name: string;
}
const props = defineProps<{
animal: T;
}>();
</script> Array works as mentioned in the comment above. But I need it also for a single generic object. |
I created a fresh repo using
npm init vue@latest
the repo can be found here, vue-generic-test.The problematic file is src/components/GenericComponent.vue
When I try to access a prop I'm my IDE shows the following error:
If I remove the usage of the generic from props, the error goes away.
Apologies if this is already a known issue, or if I'm just being dumb. Let me know if I can provide any more information.
To be clear I'm using VS code, volar 1.8.5, typescript 5.0.4, vue 3.3.4, vue-tsc 1.8.5.
The text was updated successfully, but these errors were encountered: