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

Generic Components cannot utilize InstanceType #3292

Closed
Shyam-Chen opened this issue Jun 16, 2023 · 2 comments
Closed

Generic Components cannot utilize InstanceType #3292

Shyam-Chen opened this issue Jun 16, 2023 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@Shyam-Chen
Copy link

Shyam-Chen commented Jun 16, 2023

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-xhzw3g?file=src%2Fcomponents%2FFoo.vue,src%2FApp.vue&terminal=dev

Steps to reproduce

<!-- Foo.vue -->
<script lang="ts" setup generic="T extends object">
defineProps<{
  rows?: T[];
}>();
</script>

<template>
  <div>Foo</div>
</template>
<!-- App.vue -->
<script lang="ts" setup>
import Foo from './components/Foo.vue';

type FooInstance = InstanceType<typeof Foo>;
</script>
$ npm run build

> [email protected] build
> vue-tsc && vite build

src/App.vue:5:33 - error TS2344: Type '<T extends object>(__VLS_props: { rows?: T[] | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps, __VLS_ctx?: Pick<...> | undefined, __VLS_setup?: { ...; }) => VNode<...> & { ...; }' does not satisfy the constraint 'abstract new (...args: any) => any'.
  Type '<T extends object>(__VLS_props: { rows?: T[] | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps, __VLS_ctx?: Pick<...> | undefined, __VLS_setup?: { ...; }) => VNode<...> & { ...; }' provides no match for the signature 'new (...args: any): any'.

5 type FooInstance = InstanceType<typeof Foo>;
@so1ve
Copy link
Member

so1ve commented Jun 16, 2023

Use ReturnType
Ah I see you are using generics

@so1ve
Copy link
Member

so1ve commented Jun 27, 2023

Duplicate of #3206

@so1ve so1ve marked this as a duplicate of #3206 Jun 27, 2023
@so1ve so1ve closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
@so1ve so1ve added the duplicate This issue or pull request already exists label Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants