@@ -118,8 +118,10 @@ export interface ComponentOptionsBase<
118
118
Extends extends ComponentOptionsMixin ,
119
119
E extends EmitsOptions ,
120
120
EE extends string = string ,
121
- Defaults = { }
122
- > extends LegacyOptions < Props , D , C , M , Mixin , Extends > ,
121
+ Defaults = { } ,
122
+ I extends ComponentInjectOptions = { } ,
123
+ II extends string = string
124
+ > extends LegacyOptions < Props , D , C , M , Mixin , Extends , I , II > ,
123
125
ComponentInternalOptions ,
124
126
ComponentCustomOptions {
125
127
setup ?: (
@@ -225,7 +227,9 @@ export type ComponentOptionsWithoutProps<
225
227
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
226
228
E extends EmitsOptions = EmitsOptions ,
227
229
EE extends string = string ,
228
- PE = Props & EmitsToProps < E >
230
+ I extends ComponentInjectOptions = { } ,
231
+ II extends string = string ,
232
+ PE = Props & EmitsToProps < E > ,
229
233
> = ComponentOptionsBase <
230
234
PE ,
231
235
RawBindings ,
@@ -236,11 +240,13 @@ export type ComponentOptionsWithoutProps<
236
240
Extends ,
237
241
E ,
238
242
EE ,
239
- { }
243
+ { } ,
244
+ I ,
245
+ II
240
246
> & {
241
247
props ?: undefined
242
248
} & ThisType <
243
- CreateComponentPublicInstance < PE , RawBindings , D , C , M , Mixin , Extends , E >
249
+ CreateComponentPublicInstance < PE , RawBindings , D , C , M , Mixin , Extends , E , PE , { } , false , I >
244
250
>
245
251
246
252
export type ComponentOptionsWithArrayProps <
@@ -253,6 +259,8 @@ export type ComponentOptionsWithArrayProps<
253
259
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
254
260
E extends EmitsOptions = EmitsOptions ,
255
261
EE extends string = string ,
262
+ I extends ComponentInjectOptions = { } ,
263
+ II extends string = string ,
256
264
Props = Readonly < { [ key in PropNames ] ?: any } > & EmitsToProps < E >
257
265
> = ComponentOptionsBase <
258
266
Props ,
@@ -264,7 +272,9 @@ export type ComponentOptionsWithArrayProps<
264
272
Extends ,
265
273
E ,
266
274
EE ,
267
- { }
275
+ { } ,
276
+ I ,
277
+ II
268
278
> & {
269
279
props : PropNames [ ]
270
280
} & ThisType <
@@ -276,7 +286,11 @@ export type ComponentOptionsWithArrayProps<
276
286
M ,
277
287
Mixin ,
278
288
Extends ,
279
- E
289
+ E ,
290
+ Props ,
291
+ { } ,
292
+ false ,
293
+ I
280
294
>
281
295
>
282
296
@@ -290,8 +304,10 @@ export type ComponentOptionsWithObjectProps<
290
304
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
291
305
E extends EmitsOptions = EmitsOptions ,
292
306
EE extends string = string ,
307
+ I extends ComponentInjectOptions = { } ,
308
+ II extends string = string ,
293
309
Props = Readonly < ExtractPropTypes < PropsOptions > > & EmitsToProps < E > ,
294
- Defaults = ExtractDefaultPropTypes < PropsOptions >
310
+ Defaults = ExtractDefaultPropTypes < PropsOptions > ,
295
311
> = ComponentOptionsBase <
296
312
Props ,
297
313
RawBindings ,
@@ -302,7 +318,9 @@ export type ComponentOptionsWithObjectProps<
302
318
Extends ,
303
319
E ,
304
320
EE ,
305
- Defaults
321
+ Defaults ,
322
+ I ,
323
+ II
306
324
> & {
307
325
props : PropsOptions & ThisType < void >
308
326
} & ThisType <
@@ -317,7 +335,8 @@ export type ComponentOptionsWithObjectProps<
317
335
E ,
318
336
Props ,
319
337
Defaults ,
320
- false
338
+ false ,
339
+ I
321
340
>
322
341
>
323
342
@@ -389,20 +408,32 @@ export type ComponentProvideOptions = ObjectProvideOptions | Function
389
408
390
409
type ObjectProvideOptions = Record < string | symbol , unknown >
391
410
392
- type ComponentInjectOptions = string [ ] | ObjectInjectOptions
411
+ export type ComponentInjectOptions = string [ ] | ObjectInjectOptions
393
412
394
413
type ObjectInjectOptions = Record <
395
414
string | symbol ,
396
415
string | symbol | { from ?: string | symbol ; default ?: unknown }
397
416
>
398
417
418
+ export type InjectToObject < T extends ComponentInjectOptions > = T extends string [ ]
419
+ ? {
420
+ [ K in T [ number ] ] ?: unknown
421
+ }
422
+ : T extends ObjectInjectOptions
423
+ ? {
424
+ [ K in keyof T ] ?: unknown
425
+ }
426
+ : never
427
+
399
428
interface LegacyOptions <
400
429
Props ,
401
430
D ,
402
431
C extends ComputedOptions ,
403
432
M extends MethodOptions ,
404
433
Mixin extends ComponentOptionsMixin ,
405
- Extends extends ComponentOptionsMixin
434
+ Extends extends ComponentOptionsMixin ,
435
+ I extends ComponentInjectOptions ,
436
+ II extends string
406
437
> {
407
438
compatConfig ?: CompatConfig
408
439
@@ -437,7 +468,7 @@ interface LegacyOptions<
437
468
methods ?: M
438
469
watch ?: ComponentWatchOptions
439
470
provide ?: ComponentProvideOptions
440
- inject ?: ComponentInjectOptions
471
+ inject ?: I | II [ ]
441
472
442
473
// assets
443
474
filters ?: Record < string , Function >
0 commit comments