File tree 2 files changed +22
-9
lines changed
packages/runtime-core/src
packages-private/dts-test
2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -906,12 +906,15 @@ describe('emits', () => {
906
906
emits : {
907
907
click : ( n : number ) => typeof n === 'number' ,
908
908
input : ( b : string ) => b . length > 1 ,
909
+ Focus : ( f : boolean ) => ! ! f ,
909
910
} ,
910
911
setup ( props , { emit } ) {
911
912
expectType < ( ( n : number ) => boolean ) | undefined > ( props . onClick )
912
913
expectType < ( ( b : string ) => boolean ) | undefined > ( props . onInput )
914
+ expectType < ( ( f : boolean ) => boolean ) | undefined > ( props . onFocus )
913
915
emit ( 'click' , 1 )
914
916
emit ( 'input' , 'foo' )
917
+ emit ( 'Focus' , true )
915
918
// @ts -expect-error
916
919
emit ( 'nope' )
917
920
// @ts -expect-error
@@ -922,6 +925,10 @@ describe('emits', () => {
922
925
emit ( 'input' )
923
926
// @ts -expect-error
924
927
emit ( 'input' , 1 )
928
+ // @ts -expect-error
929
+ emit ( 'focus' )
930
+ // @ts -expect-error
931
+ emit ( 'focus' , true )
925
932
} ,
926
933
created ( ) {
927
934
this . $emit ( 'click' , 1 )
@@ -936,6 +943,10 @@ describe('emits', () => {
936
943
this . $emit ( 'input' )
937
944
// @ts -expect-error
938
945
this . $emit ( 'input' , 1 )
946
+ // @ts -expect-error
947
+ this . $emit ( 'focus' )
948
+ // @ts -expect-error
949
+ this . $emit ( 'focus' , true )
939
950
} ,
940
951
mounted ( ) {
941
952
// #3599
@@ -954,6 +965,10 @@ describe('emits', () => {
954
965
this . $emit ( 'input' )
955
966
// @ts -expect-error
956
967
this . $emit ( 'input' , 1 )
968
+ // @ts -expect-error
969
+ this . $emit ( 'focus' )
970
+ // @ts -expect-error
971
+ this . $emit ( 'focus' , true )
957
972
} )
958
973
} ,
959
974
} )
Original file line number Diff line number Diff line change @@ -47,15 +47,13 @@ export type EmitsToProps<T extends EmitsOptions | ComponentTypeEmits> =
47
47
}
48
48
: T extends ObjectEmitsOptions
49
49
? {
50
- [ K in `on${Capitalize < string & keyof T > } `] ?: K extends `on${infer C } `
51
- ? (
52
- ...args : T [ Uncapitalize < C > ] extends ( ...args : infer P ) => any
53
- ? P
54
- : T [ Uncapitalize < C > ] extends null
55
- ? any [ ]
56
- : never
57
- ) => any
58
- : never
50
+ [ K in string & keyof T as `on${Capitalize < K > } `] ?: (
51
+ ...args : T [ K ] extends ( ...args : infer P ) => any
52
+ ? P
53
+ : T [ K ] extends null
54
+ ? any [ ]
55
+ : never
56
+ ) => any
59
57
}
60
58
: { }
61
59
You can’t perform that action at this time.
0 commit comments