Skip to content

Generic Components cannot utilize InstanceType #3292

@Shyam-Chen

Description

@Shyam-Chen

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

> vite-vue-typescript-starter@0.0.0 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>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions