[Feature Request] 希望组件能够显式声明 Slots 类型
Author: SyeelingCreated Aug 23, 2026Updated Aug 23, 2026
Labelsfeature: need confirm
What problem does this feature solve?
Vant 组件当前并没有导出或声明 Slots 类型。
What does the proposed API look like?
以 VanField 组件为例:
当前组件定义:
// Field.tsx
// 其它代码...
export default defineComponent({
name,
props: fieldProps,
emits: [
'blur',
'focus',
'clear',
// 其它 events...
],
setup(props, { emit, slots }) {
// 其它代码...
}
})希望增加 Slots 的类型声明:
// Field.tsx
import { SlotsType } from 'vue'
// 其它代码...
export default defineComponent({
name,
props: fieldProps,
emits: [
'blur',
'focus',
'clear',
// 其它 events...
],
slots: Object as SlotsType<{
label: {}
input: {}
'error-message': { message: string }
// 其它 slots...
}>,
setup(props, { emit, slots }) {
// 其它代码...
}
})Source: youzan/vant