import { isFunction } from '@vue/shared'
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
// (uses user defined props interface)
export function createComponent<Props, RawBindings = object>(
>(
options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M>
): {
- // for Vetur and TSX support
new (): ComponentPublicInstance<
ExtractPropTypes<PropsOptions>,
RawBindings,
-import { createComponent } from '../apiCreateComponent'
-import { getCurrentInstance, ComponentInternalInstance } from '../component'
+import {
+ getCurrentInstance,
+ ComponentInternalInstance,
+ SetupContext,
+ ComponentOptions
+} from '../component'
import { cloneVNode, Comment, isSameVNodeType, VNode } from '../vnode'
import { warn } from '../warning'
import { isKeepAlive } from './KeepAlive'
onLeaveCancelled?: (el: any) => void
}
-export const Transition = createComponent({
+const TransitionImpl = {
name: `Transition`,
- setup(props: TransitionProps, { slots }) {
+ setup(props: TransitionProps, { slots }: SetupContext) {
const instance = getCurrentInstance()!
let isLeaving = false
let isMounted = false
return child
}
}
-})
+}
if (__DEV__) {
- ;(Transition as any).props = {
+ ;(TransitionImpl as ComponentOptions).props = {
mode: String,
appear: Boolean,
// enter
}
}
+// 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 {
beforeEnter(el: object): void
enter(el: object): void