mirror of https://github.com/vuejs/core.git
fix(types): respect props with default on instance type when using __typeProps
This commit is contained in:
parent
cd0ea0d479
commit
96e4738334
|
@ -1972,3 +1972,24 @@ createApp({}).component(
|
|||
},
|
||||
}),
|
||||
)
|
||||
|
||||
const Comp = defineComponent({
|
||||
props: {
|
||||
actionText: {
|
||||
type: {} as PropType<string>,
|
||||
default: 'Become a sponsor',
|
||||
},
|
||||
},
|
||||
__typeProps: {} as {
|
||||
actionText?: string
|
||||
},
|
||||
})
|
||||
|
||||
const instance = new Comp()
|
||||
function expectString(s: string) {}
|
||||
// instance prop with default should be non-null
|
||||
expectString(instance.actionText)
|
||||
|
||||
// public prop on $props should be optional
|
||||
// @ts-expect-error
|
||||
expectString(instance.$props.actionText)
|
||||
|
|
|
@ -292,7 +292,7 @@ export type ComponentPublicInstance<
|
|||
C extends ComputedOptions = {},
|
||||
M extends MethodOptions = {},
|
||||
E extends EmitsOptions = {},
|
||||
PublicProps = P,
|
||||
PublicProps = {},
|
||||
Defaults = {},
|
||||
MakeDefaultsOptional extends boolean = false,
|
||||
Options = ComponentOptionsBase<any, any, any, any, any, any, any, any, any>,
|
||||
|
@ -323,7 +323,11 @@ export type ComponentPublicInstance<
|
|||
options?: WatchOptions,
|
||||
): WatchStopHandle
|
||||
} & ExposedKeys<
|
||||
IfAny<P, P, Omit<P, keyof ShallowUnwrapRef<B>>> &
|
||||
IfAny<
|
||||
P,
|
||||
P,
|
||||
Readonly<Defaults> & Omit<P, keyof ShallowUnwrapRef<B> | keyof Defaults>
|
||||
> &
|
||||
ShallowUnwrapRef<B> &
|
||||
UnwrapNestedRefs<D> &
|
||||
ExtractComputedReturns<C> &
|
||||
|
|
Loading…
Reference in New Issue