expectType<Slots | undefined>(new comp2().$slots)
})
+// #5885
+describe('should work when props type is incompatible with setup returned type ', () => {
+ type SizeType = 'small' | 'big'
+ const Comp = defineComponent({
+ props: {
+ size: {
+ type: String as PropType<SizeType>,
+ required: true
+ }
+ },
+ setup(props) {
+ expectType<SizeType>(props.size)
+ return {
+ size: 1
+ }
+ }
+ })
+ type CompInstance = InstanceType<typeof Comp>
+
+ const CompA = {} as CompInstance
+ expectType<ComponentPublicInstance>(CompA)
+ expectType<number>(CompA.size)
+ expectType<SizeType>(CompA.$props.size)
+})
+
import {
DefineComponent,
ComponentOptionsMixin,
isString,
isFunction,
UnionToIntersection,
- Prettify
+ Prettify,
+ IfAny
} from '@vue/shared'
import {
toRaw,
I,
S
>
-
// public properties exposed on the proxy, which is used as the render context
// in templates (as `this` in the render option)
export type ComponentPublicInstance<
: (...args: any) => any,
options?: WatchOptions
): WatchStopHandle
-} & P &
+} & IfAny<P, P, Omit<P, keyof ShallowUnwrapRef<B>>> &
ShallowUnwrapRef<B> &
UnwrapNestedRefs<D> &
ExtractComputedReturns<C> &