Skip to content

Support component instance types #527

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

Open
3 tasks done
XioDone opened this issue Oct 19, 2022 · 1 comment
Open
3 tasks done

Support component instance types #527

XioDone opened this issue Oct 19, 2022 · 1 comment
Labels
enhancement New feature or request pr welcome

Comments

@XioDone
Copy link

XioDone commented Oct 19, 2022

Clear and concise description of the problem

The method exposed by the component, refer to the component in the template, you need to manually import the component in the script, add a type.

const myFormRef = ref<InstanceType<typeof MyForm>>()

<template>
  <MyForm ref="myFormRef"/>
</template>

Suggested solution

Add a switch to option, automatically declare the instance type of a component in components.d.ts
image

// components.d.ts
export interface GlobalComponents {
  MyForm: typeof import('./components/MyForm.vue')['default']
  MyFormInstance: InstanceType<GlobalComponents['MyForm']>
}

Maybe there's a more elegant way.

Alternative

No response

Additional context

No response

Validations

@XioDone XioDone added the enhancement New feature or request label Oct 19, 2022
@qcp qcp mentioned this issue Feb 16, 2023
3 tasks
@moliyu
Copy link

moliyu commented Oct 31, 2024

this solution cannot support with component with setup genric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr welcome
Projects
None yet
Development

No branches or pull requests

3 participants