types: fix Transition exported typing
This commit is contained in:
parent
79f23a2f77
commit
21c41b3228
@ -11,6 +11,11 @@ import { ExtractPropTypes, ComponentPropsOptions } from './componentProps'
|
|||||||
import { isFunction } from '@vue/shared'
|
import { isFunction } from '@vue/shared'
|
||||||
import { VNodeProps } from './vnode'
|
import { VNodeProps } from './vnode'
|
||||||
|
|
||||||
|
// createComponent is a utility that is primarily used for type inference
|
||||||
|
// when declaring components. Type inference is provided in the component
|
||||||
|
// options (provided as the argument). The returned value has artifical types
|
||||||
|
// for TSX / manual render function / IDE support.
|
||||||
|
|
||||||
// overload 1: direct setup function
|
// overload 1: direct setup function
|
||||||
// (uses user defined props interface)
|
// (uses user defined props interface)
|
||||||
export function createComponent<Props, RawBindings = object>(
|
export function createComponent<Props, RawBindings = object>(
|
||||||
@ -81,7 +86,6 @@ export function createComponent<
|
|||||||
>(
|
>(
|
||||||
options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M>
|
options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M>
|
||||||
): {
|
): {
|
||||||
// for Vetur and TSX support
|
|
||||||
new (): ComponentPublicInstance<
|
new (): ComponentPublicInstance<
|
||||||
ExtractPropTypes<PropsOptions>,
|
ExtractPropTypes<PropsOptions>,
|
||||||
RawBindings,
|
RawBindings,
|
||||||
|
@ -210,6 +210,7 @@ const KeepAliveImpl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// export the public type for h/tsx inference
|
// export the public type for h/tsx inference
|
||||||
|
// also to avoid inline import() in generated d.ts files
|
||||||
export const KeepAlive = (KeepAliveImpl as any) as {
|
export const KeepAlive = (KeepAliveImpl as any) as {
|
||||||
new (): {
|
new (): {
|
||||||
$props: KeepAliveProps
|
$props: KeepAliveProps
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import { createComponent } from '../apiCreateComponent'
|
import {
|
||||||
import { getCurrentInstance, ComponentInternalInstance } from '../component'
|
getCurrentInstance,
|
||||||
|
ComponentInternalInstance,
|
||||||
|
SetupContext,
|
||||||
|
ComponentOptions
|
||||||
|
} from '../component'
|
||||||
import { cloneVNode, Comment, isSameVNodeType, VNode } from '../vnode'
|
import { cloneVNode, Comment, isSameVNodeType, VNode } from '../vnode'
|
||||||
import { warn } from '../warning'
|
import { warn } from '../warning'
|
||||||
import { isKeepAlive } from './KeepAlive'
|
import { isKeepAlive } from './KeepAlive'
|
||||||
@ -26,9 +30,9 @@ export interface TransitionProps {
|
|||||||
onLeaveCancelled?: (el: any) => void
|
onLeaveCancelled?: (el: any) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Transition = createComponent({
|
const TransitionImpl = {
|
||||||
name: `Transition`,
|
name: `Transition`,
|
||||||
setup(props: TransitionProps, { slots }) {
|
setup(props: TransitionProps, { slots }: SetupContext) {
|
||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
let isLeaving = false
|
let isLeaving = false
|
||||||
let isMounted = false
|
let isMounted = false
|
||||||
@ -108,10 +112,10 @@ export const Transition = createComponent({
|
|||||||
return child
|
return child
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
;(Transition as any).props = {
|
;(TransitionImpl as ComponentOptions).props = {
|
||||||
mode: String,
|
mode: String,
|
||||||
appear: Boolean,
|
appear: Boolean,
|
||||||
// enter
|
// enter
|
||||||
@ -127,6 +131,14 @@ if (__DEV__) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export the public type for h/tsx inference
|
||||||
|
// also to avoid inline import() in generated d.ts files
|
||||||
|
export const Transition = (TransitionImpl as any) as {
|
||||||
|
new (): {
|
||||||
|
$props: TransitionProps
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export interface TransitionData {
|
export interface TransitionData {
|
||||||
beforeEnter(el: object): void
|
beforeEnter(el: object): void
|
||||||
enter(el: object): void
|
enter(el: object): void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user