fix(types): properly infer return type from async setup (#2051)
fix #2049
This commit is contained in:
@@ -5,7 +5,8 @@ import {
|
||||
ComponentOptionsWithArrayProps,
|
||||
ComponentOptionsWithObjectProps,
|
||||
ComponentOptionsMixin,
|
||||
RenderFunction
|
||||
RenderFunction,
|
||||
UnwrapAsyncBindings
|
||||
} from './componentOptions'
|
||||
import {
|
||||
SetupContext,
|
||||
@@ -37,7 +38,7 @@ export function defineComponent<Props, RawBindings = object>(
|
||||
): ComponentPublicInstanceConstructor<
|
||||
CreateComponentPublicInstance<
|
||||
Props,
|
||||
RawBindings,
|
||||
UnwrapAsyncBindings<RawBindings>,
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
@@ -78,7 +79,7 @@ export function defineComponent<
|
||||
): ComponentPublicInstanceConstructor<
|
||||
CreateComponentPublicInstance<
|
||||
Props,
|
||||
RawBindings,
|
||||
UnwrapAsyncBindings<RawBindings>,
|
||||
D,
|
||||
C,
|
||||
M,
|
||||
@@ -130,7 +131,7 @@ export function defineComponent<
|
||||
// but now we can export array props in TSX
|
||||
CreateComponentPublicInstance<
|
||||
Readonly<{ [key in PropNames]?: any }>,
|
||||
RawBindings,
|
||||
UnwrapAsyncBindings<RawBindings>,
|
||||
D,
|
||||
C,
|
||||
M,
|
||||
@@ -181,7 +182,7 @@ export function defineComponent<
|
||||
): ComponentPublicInstanceConstructor<
|
||||
CreateComponentPublicInstance<
|
||||
ExtractPropTypes<PropsOptions, false>,
|
||||
RawBindings,
|
||||
UnwrapAsyncBindings<RawBindings>,
|
||||
D,
|
||||
C,
|
||||
M,
|
||||
|
||||
@@ -72,6 +72,8 @@ export interface ComponentCustomOptions {}
|
||||
|
||||
export type RenderFunction = () => VNodeChild
|
||||
|
||||
export type UnwrapAsyncBindings<T> = T extends Promise<infer S> ? S : T
|
||||
|
||||
export interface ComponentOptionsBase<
|
||||
Props,
|
||||
RawBindings,
|
||||
|
||||
@@ -27,7 +27,8 @@ import {
|
||||
OptionTypesType,
|
||||
OptionTypesKeys,
|
||||
resolveMergedOptions,
|
||||
isInBeforeCreate
|
||||
isInBeforeCreate,
|
||||
UnwrapAsyncBindings
|
||||
} from './componentOptions'
|
||||
import { EmitsOptions, EmitFn } from './componentEmits'
|
||||
import { Slots } from './componentSlots'
|
||||
@@ -168,7 +169,7 @@ export type ComponentPublicInstance<
|
||||
options?: WatchOptions
|
||||
): WatchStopHandle
|
||||
} & P &
|
||||
ShallowUnwrapRef<B> &
|
||||
ShallowUnwrapRef<UnwrapAsyncBindings<B>> &
|
||||
D &
|
||||
ExtractComputedReturns<C> &
|
||||
M &
|
||||
|
||||
Reference in New Issue
Block a user