tiny-vue icon indicating copy to clipboard operation
tiny-vue copied to clipboard

✨ [Feature]: Request for support of ComponentPublicInstance for type inference in TypeScript

Open sweetwisdom opened this issue 2 months ago • 0 comments

What problem does this feature solve

描述:

在 Vue 3 中,ComponentPublicInstance 类型可以帮助我们获取组件实例的公共属性类型,方便通过 ref 访问组件的公开方法时提供类型提示。然而,当前 tiny-vue 组件库似乎不支持这种类型推导。

重现步骤:

Image
  1. 使用 ref 获取组件实例:

    import { ref } from 'vue'
    import { Form } from '@opentiny/vue'
    const formRef = useTemplateRef('formRef')
    formRef.value?.resetFields() // 无法提供类型提示
    
  2. 发现无法自动推导类型,resetFields 方法没有代码提示。

期望的行为:

Image

希望 tiny-vue 能支持 ComponentPublicInstance 类型的推导,或者提供一种方式,使得 ref 可以正确推导组件实例的公共方法和属性。

What does the proposed API look like

如上文

What is your project name

sweetwisdom

sweetwisdom avatar Sep 24 '25 07:09 sweetwisdom