@@ -65,6 +65,15 @@ interface ComponentOptionsWithProps<
6565 setup ?: SetupFunction < Props , RawBindings > ;
6666}
6767
68+ interface ComponentOptionsWithArrayProps <
69+ PropNames extends string = string ,
70+ RawBindings = Data ,
71+ Props = Readonly < { [ key in PropNames ] ?: any } >
72+ > {
73+ props ?: PropNames [ ] ;
74+ setup ?: SetupFunction < Props , RawBindings > ;
75+ }
76+
6877interface ComponentOptionsWithoutProps < Props = unknown , RawBindings = Data > {
6978 props ?: undefined ;
7079 setup ?: SetupFunction < Props , RawBindings > ;
@@ -74,7 +83,20 @@ interface ComponentOptionsWithoutProps<Props = unknown, RawBindings = Data> {
7483export function defineComponent < RawBindings > (
7584 options : ComponentOptionsWithoutProps < unknown , RawBindings >
7685) : VueProxy < unknown , RawBindings > ;
77- // overload 2: object format with object props declaration
86+ // overload 2: object format with array props declaration
87+ // props inferred as { [key in PropNames]?: any }
88+ // return type is for Vetur and TSX support
89+ export function defineComponent <
90+ PropNames extends string ,
91+ RawBindings = Data ,
92+ PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
93+ > (
94+ // prettier-ignore
95+ options : (
96+ ComponentOptionsWithArrayProps < PropNames , RawBindings > ) &
97+ Omit < Vue2ComponentOptions < Vue > , keyof ComponentOptionsWithProps < never , never > >
98+ ) : VueProxy < Readonly < { [ key in PropNames ] ?: any } > , RawBindings > ;
99+ // overload 3: object format with object props declaration
78100// see `ExtractPropTypes` in ./componentProps.ts
79101export function defineComponent <
80102 Props ,
@@ -94,12 +116,24 @@ export function defineComponent(options: any) {
94116 return options as any ;
95117}
96118
97- // createComponent is kept around for retro-compatibility
98119// overload 1: object format with no props
99120export function createComponent < RawBindings > (
100121 options : ComponentOptionsWithoutProps < unknown , RawBindings >
101122) : VueProxy < unknown , RawBindings > ;
102- // overload 2: object format with object props declaration
123+ // overload 2: object format with array props declaration
124+ // props inferred as { [key in PropNames]?: any }
125+ // return type is for Vetur and TSX support
126+ export function createComponent <
127+ PropNames extends string ,
128+ RawBindings = Data ,
129+ PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
130+ > (
131+ // prettier-ignore
132+ options : (
133+ ComponentOptionsWithArrayProps < PropNames , RawBindings > ) &
134+ Omit < Vue2ComponentOptions < Vue > , keyof ComponentOptionsWithProps < never , never > >
135+ ) : VueProxy < Readonly < { [ key in PropNames ] ?: any } > , RawBindings > ;
136+ // overload 3: object format with object props declaration
103137// see `ExtractPropTypes` in ./componentProps.ts
104138export function createComponent <
105139 Props ,
0 commit comments