|
|
@@ -7,18 +7,15 @@ import {
|
|
|
} from './apiOptions'
|
|
|
import { SetupContext, RenderFunction } from './component'
|
|
|
import { ComponentPublicInstance } from './componentProxy'
|
|
|
-import { ExtractPropTypes } from './componentProps'
|
|
|
+import { ExtractPropTypes, ComponentPropsOptions } from './componentProps'
|
|
|
import { isFunction } from '@vue/shared'
|
|
|
import { VNodeProps } from './vnode'
|
|
|
|
|
|
// overload 1: direct setup function
|
|
|
// (uses user defined props interface)
|
|
|
-// __isConstructor: true is a type-only differentiator to avoid returned
|
|
|
-// constructor type from being matched as an options object in h()
|
|
|
export function createComponent<Props, RawBindings = object>(
|
|
|
setup: (props: Props, ctx: SetupContext) => RawBindings | RenderFunction
|
|
|
): {
|
|
|
- __isConstructor: true
|
|
|
new (): ComponentPublicInstance<
|
|
|
Props,
|
|
|
RawBindings,
|
|
|
@@ -42,7 +39,6 @@ export function createComponent<
|
|
|
>(
|
|
|
options: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M>
|
|
|
): {
|
|
|
- __isConstructor: true
|
|
|
new (): ComponentPublicInstance<
|
|
|
Props,
|
|
|
RawBindings,
|
|
|
@@ -65,7 +61,6 @@ export function createComponent<
|
|
|
>(
|
|
|
options: ComponentOptionsWithArrayProps<PropNames, RawBindings, D, C, M>
|
|
|
): {
|
|
|
- __isConstructor: true
|
|
|
// array props technically doesn't place any contraints on props in TSX
|
|
|
new (): ComponentPublicInstance<VNodeProps, RawBindings, D, C, M>
|
|
|
}
|
|
|
@@ -73,7 +68,7 @@ export function createComponent<
|
|
|
// overload 4: object format with object props declaration
|
|
|
// see `ExtractPropTypes` in ./componentProps.ts
|
|
|
export function createComponent<
|
|
|
- PropsOptions,
|
|
|
+ PropsOptions extends Readonly<ComponentPropsOptions>,
|
|
|
RawBindings,
|
|
|
D,
|
|
|
C extends ComputedOptions = {},
|
|
|
@@ -81,10 +76,9 @@ export function createComponent<
|
|
|
>(
|
|
|
options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M>
|
|
|
): {
|
|
|
- __isConstructor: true
|
|
|
// for Vetur and TSX support
|
|
|
new (): ComponentPublicInstance<
|
|
|
- ExtractPropTypes<PropsOptions, false>,
|
|
|
+ ExtractPropTypes<PropsOptions>,
|
|
|
RawBindings,
|
|
|
D,
|
|
|
C,
|