@@ -51,7 +51,7 @@ import {
51
51
ExtractPropTypes ,
52
52
ExtractDefaultPropTypes
53
53
} from './componentProps'
54
- import { EmitsOptions } from './componentEmits'
54
+ import { EmitsOptions , EmitsToProps } from './componentEmits'
55
55
import { Directive } from './directives'
56
56
import {
57
57
CreateComponentPublicInstance ,
@@ -91,16 +91,18 @@ export interface ComponentCustomOptions {}
91
91
export type RenderFunction = ( ) => VNodeChild
92
92
93
93
type ExtractOptionProp < T > = T extends ComponentOptionsBase <
94
- infer P ,
95
- any ,
96
- any ,
97
- any ,
98
- any ,
99
- any ,
100
- any ,
101
- any
94
+ infer P , // Props
95
+ any , // RawBindings
96
+ any , // D
97
+ any , // C
98
+ any , // M
99
+ any , // Mixin
100
+ any , // Extends
101
+ any // EmitsOptions
102
102
>
103
- ? unknown extends P ? { } : P
103
+ ? unknown extends P
104
+ ? { }
105
+ : P
104
106
: { }
105
107
106
108
export interface ComponentOptionsBase <
@@ -114,8 +116,7 @@ export interface ComponentOptionsBase<
114
116
E extends EmitsOptions ,
115
117
EE extends string = string ,
116
118
Defaults = { }
117
- >
118
- extends LegacyOptions < Props , D , C , M , Mixin , Extends > ,
119
+ > extends LegacyOptions < Props , D , C , M , Mixin , Extends > ,
119
120
ComponentInternalOptions ,
120
121
ComponentCustomOptions {
121
122
setup ?: (
@@ -220,9 +221,10 @@ export type ComponentOptionsWithoutProps<
220
221
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin ,
221
222
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
222
223
E extends EmitsOptions = EmitsOptions ,
223
- EE extends string = string
224
+ EE extends string = string ,
225
+ PE = Props & EmitsToProps < E >
224
226
> = ComponentOptionsBase <
225
- Props ,
227
+ PE ,
226
228
RawBindings ,
227
229
D ,
228
230
C ,
@@ -235,7 +237,7 @@ export type ComponentOptionsWithoutProps<
235
237
> & {
236
238
props ?: undefined
237
239
} & ThisType <
238
- CreateComponentPublicInstance < { } , RawBindings , D , C , M , Mixin , Extends , E >
240
+ CreateComponentPublicInstance < PE , RawBindings , D , C , M , Mixin , Extends , E >
239
241
>
240
242
241
243
export type ComponentOptionsWithArrayProps <
@@ -248,7 +250,7 @@ export type ComponentOptionsWithArrayProps<
248
250
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
249
251
E extends EmitsOptions = EmitsOptions ,
250
252
EE extends string = string ,
251
- Props = Readonly < { [ key in PropNames ] ?: any } >
253
+ Props = Readonly < { [ key in PropNames ] ?: any } > & EmitsToProps < E >
252
254
> = ComponentOptionsBase <
253
255
Props ,
254
256
RawBindings ,
@@ -285,7 +287,7 @@ export type ComponentOptionsWithObjectProps<
285
287
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
286
288
E extends EmitsOptions = EmitsOptions ,
287
289
EE extends string = string ,
288
- Props = Readonly < ExtractPropTypes < PropsOptions > > ,
290
+ Props = Readonly < ExtractPropTypes < PropsOptions > > & EmitsToProps < E > ,
289
291
Defaults = ExtractDefaultPropTypes < PropsOptions >
290
292
> = ComponentOptionsBase <
291
293
Props ,
@@ -365,7 +367,9 @@ export interface MethodOptions {
365
367
export type ExtractComputedReturns < T extends any > = {
366
368
[ key in keyof T ] : T [ key ] extends { get : ( ...args : any [ ] ) => infer TReturn }
367
369
? TReturn
368
- : T [ key ] extends ( ...args : any [ ] ) => infer TReturn ? TReturn : never
370
+ : T [ key ] extends ( ...args : any [ ] ) => infer TReturn
371
+ ? TReturn
372
+ : never
369
373
}
370
374
371
375
export type ObjectWatchOptionItem = {
@@ -471,7 +475,7 @@ interface LegacyOptions<
471
475
__differentiator ?: keyof D | keyof C | keyof M
472
476
}
473
477
474
- type MergedHook < T = ( ( ) => void ) > = T | T [ ]
478
+ type MergedHook < T = ( ) => void > = T | T [ ]
475
479
476
480
export type MergedComponentOptions = ComponentOptions &
477
481
MergedComponentOptionsOverride
@@ -679,21 +683,21 @@ export function applyOptions(instance: ComponentInternalInstance) {
679
683
const get = isFunction ( opt )
680
684
? opt . bind ( publicThis , publicThis )
681
685
: isFunction ( opt . get )
682
- ? opt . get . bind ( publicThis , publicThis )
683
- : NOOP
686
+ ? opt . get . bind ( publicThis , publicThis )
687
+ : NOOP
684
688
if ( __DEV__ && get === NOOP ) {
685
689
warn ( `Computed property "${ key } " has no getter.` )
686
690
}
687
691
const set =
688
692
! isFunction ( opt ) && isFunction ( opt . set )
689
693
? opt . set . bind ( publicThis )
690
694
: __DEV__
691
- ? ( ) => {
692
- warn (
693
- `Write operation failed: computed property "${ key } " is readonly.`
694
- )
695
- }
696
- : NOOP
695
+ ? ( ) => {
696
+ warn (
697
+ `Write operation failed: computed property "${ key } " is readonly.`
698
+ )
699
+ }
700
+ : NOOP
697
701
const c = computed ( {
698
702
get,
699
703
set
@@ -1006,10 +1010,11 @@ function mergeDataFn(to: any, from: any) {
1006
1010
return from
1007
1011
}
1008
1012
return function mergedDataFn ( this : ComponentPublicInstance ) {
1009
- return ( __COMPAT__ &&
1010
- isCompatEnabled ( DeprecationTypes . OPTIONS_DATA_MERGE , null )
1011
- ? deepMergeData
1012
- : extend ) (
1013
+ return (
1014
+ __COMPAT__ && isCompatEnabled ( DeprecationTypes . OPTIONS_DATA_MERGE , null )
1015
+ ? deepMergeData
1016
+ : extend
1017
+ ) (
1013
1018
isFunction ( to ) ? to . call ( this , this ) : to ,
1014
1019
isFunction ( from ) ? from . call ( this , this ) : from
1015
1020
)
0 commit comments