types(runtime-core): improve types for transition hook (#1009)

* types(runtime-core): improve types for transition hook

fix #1000

* Update packages/runtime-core/src/components/BaseTransition.ts

Co-Authored-By: Carlos Rodrigues <david-181@hotmail.com>

* fix: run ci

Co-authored-by: Carlos Rodrigues <david-181@hotmail.com>
This commit is contained in:
Evan You 2020-06-11 16:39:18 -04:00 committed by GitHub
commit 3fafc3b3ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -43,14 +43,14 @@ export interface BaseTransitionProps<HostElement = RendererElement> {
onLeaveCancelled?: (el: HostElement) => void // only fired in persisted mode onLeaveCancelled?: (el: HostElement) => void // only fired in persisted mode
} }
export interface TransitionHooks { export interface TransitionHooks<HostElement extends RendererElement = RendererElement> {
persisted: boolean persisted: boolean
beforeEnter(el: RendererElement): void beforeEnter(el: HostElement): void
enter(el: RendererElement): void enter(el: HostElement): void
leave(el: RendererElement, remove: () => void): void leave(el: HostElement, remove: () => void): void
afterLeave?(): void afterLeave?(): void
delayLeave?( delayLeave?(
el: RendererElement, el: HostElement,
earlyRemove: () => void, earlyRemove: () => void,
delayedLeave: () => void delayedLeave: () => void
): void ): void
@ -272,9 +272,9 @@ export function resolveTransitionHooks(
) )
} }
const hooks: TransitionHooks = { const hooks: TransitionHooks<TransitionElement> = {
persisted, persisted,
beforeEnter(el: TransitionElement) { beforeEnter(el) {
if (!appear && !state.isMounted) { if (!appear && !state.isMounted) {
return return
} }
@ -295,7 +295,7 @@ export function resolveTransitionHooks(
callHook(onBeforeEnter, [el]) callHook(onBeforeEnter, [el])
}, },
enter(el: TransitionElement) { enter(el) {
if (!appear && !state.isMounted) { if (!appear && !state.isMounted) {
return return
} }
@ -320,7 +320,7 @@ export function resolveTransitionHooks(
} }
}, },
leave(el: TransitionElement, remove) { leave(el, remove) {
const key = String(vnode.key) const key = String(vnode.key)
if (el._enterCb) { if (el._enterCb) {
el._enterCb(true /* cancelled */) el._enterCb(true /* cancelled */)

View File

@ -120,7 +120,7 @@ export interface VNode<HostNode = RendererNode, HostElement = RendererElement> {
component: ComponentInternalInstance | null component: ComponentInternalInstance | null
suspense: SuspenseBoundary | null suspense: SuspenseBoundary | null
dirs: DirectiveBinding[] | null dirs: DirectiveBinding[] | null
transition: TransitionHooks | null transition: TransitionHooks<HostElement> | null
// DOM // DOM
el: HostNode | null el: HostNode | null