},
})
+ // #11803 manual props annotation in setup()
+ const Hello = defineComponent({
+ name: 'HelloWorld',
+ inheritAttrs: false,
+ props: { foo: String },
+ emits: {
+ customClick: (args: string) => typeof args === 'string',
+ },
+ setup(props: { foo?: string }) {},
+ })
+ ;<Hello onCustomClick={() => {}} />
+
// without emits
defineComponent({
setup(props, { emit }) {
S
>
+type ToResolvedProps<Props, Emits extends EmitsOptions> = Readonly<Props> &
+ Readonly<EmitsToProps<Emits>>
+
// defineComponent is a utility that is primarily used for type inference
// when declaring components. Type inference is provided in the component
// options (provided as the argument). The returned value has artificial types
: ExtractPropTypes<RuntimePropsOptions>
: { [key in RuntimePropsKeys]?: any }
: TypeProps,
- ResolvedProps = Readonly<InferredProps> &
- Readonly<EmitsToProps<ResolvedEmits>>,
TypeRefs extends Record<string, unknown> = {},
>(
options: {
*/
__typeRefs?: TypeRefs
} & ComponentOptionsBase<
- ResolvedProps,
+ ToResolvedProps<InferredProps, ResolvedEmits>,
SetupBindings,
Data,
Computed,
> &
ThisType<
CreateComponentPublicInstanceWithMixins<
- ResolvedProps,
+ ToResolvedProps<InferredProps, ResolvedEmits>,
SetupBindings,
Data,
Computed,
ResolvedEmits,
RuntimeEmitsKeys,
PublicProps,
- ResolvedProps,
+ ToResolvedProps<InferredProps, ResolvedEmits>,
ExtractDefaultPropTypes<RuntimePropsOptions>,
Slots,
LocalComponents,