refactor(components): [tabs] enhance instance type (#14352)

* refactor(components): [tabs] enhance instance type

1. exports Tabs instance type

2. add expose type to TabNavInstanec

* chore: remove useless import
This commit is contained in:
Hefty 2023-09-22 10:20:46 +08:00 committed by GitHub
parent 99e8736c6a
commit bfff514f77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -406,5 +406,8 @@ const TabNav = defineComponent({
},
})
export type TabNavInstance = InstanceType<typeof TabNav>
export type TabNavInstance = InstanceType<typeof TabNav> & {
scrollToActiveTab: () => Promise<void>
removeFocus: () => void
}
export default TabNav

View File

@ -79,7 +79,7 @@ export type TabsEmits = typeof tabsEmits
export type TabsPanes = Record<number, TabsPaneContext>
export default defineComponent({
const Tabs = defineComponent({
name: 'ElTabs',
props: tabsProps,
@ -112,9 +112,6 @@ export default defineComponent({
emit('tabChange', value)
}
// call exposed function, Vue doesn't support expose in typescript yet.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
nav$.value?.removeFocus?.()
}
} catch {}
@ -166,9 +163,6 @@ export default defineComponent({
watch(currentName, async () => {
await nextTick()
// call exposed function, Vue doesn't support expose in typescript yet.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
nav$.value?.scrollToActiveTab()
})
@ -244,3 +238,9 @@ export default defineComponent({
}
},
})
export type TabsInstance = InstanceType<typeof Tabs> & {
currentName: TabPaneName
}
export default Tabs