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 = {},
|
C extends ComputedOptions = {},
|
||||||
M extends MethodOptions = {},
|
M extends MethodOptions = {},
|
||||||
E extends EmitsOptions = {},
|
E extends EmitsOptions = {},
|
||||||
PublicProps = P,
|
PublicProps = {},
|
||||||
Defaults = {},
|
Defaults = {},
|
||||||
MakeDefaultsOptional extends boolean = false,
|
MakeDefaultsOptional extends boolean = false,
|
||||||
Options = ComponentOptionsBase<any, any, any, any, any, any, any, any, any>,
|
Options = ComponentOptionsBase<any, any, any, any, any, any, any, any, any>,
|
||||||
|
@ -323,7 +323,11 @@ export type ComponentPublicInstance<
|
||||||
options?: WatchOptions,
|
options?: WatchOptions,
|
||||||
): WatchStopHandle
|
): WatchStopHandle
|
||||||
} & ExposedKeys<
|
} & ExposedKeys<
|
||||||
IfAny<P, P, Omit<P, keyof ShallowUnwrapRef<B>>> &
|
IfAny<
|
||||||
|
P,
|
||||||
|
P,
|
||||||
|
Readonly<Defaults> & Omit<P, keyof ShallowUnwrapRef<B> | keyof Defaults>
|
||||||
|
> &
|
||||||
ShallowUnwrapRef<B> &
|
ShallowUnwrapRef<B> &
|
||||||
UnwrapNestedRefs<D> &
|
UnwrapNestedRefs<D> &
|
||||||
ExtractComputedReturns<C> &
|
ExtractComputedReturns<C> &
|
||||||
|
|
Loading…
Reference in New Issue