File tree 2 files changed +22
-4
lines changed
packages/runtime-core/src
2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { ErrorCodes , callWithErrorHandling } from './errorHandling'
2
2
import { isArray } from '@vue/shared'
3
- import { ComponentPublicInstance } from './componentPublicInstance'
4
3
import { ComponentInternalInstance , getComponentName } from './component'
5
4
import { warn } from './warning'
6
5
import { ReactiveEffect } from '@vue/reactivity'
@@ -39,9 +38,9 @@ let currentPreFlushParentJob: SchedulerJob | null = null
39
38
const RECURSION_LIMIT = 100
40
39
type CountMap = Map < SchedulerJob | SchedulerCb , number >
41
40
42
- export function nextTick (
43
- this : ComponentPublicInstance | void ,
44
- fn ?: ( ) => void
41
+ export function nextTick < T = void > (
42
+ this : T ,
43
+ fn ?: ( this : T ) => void
45
44
) : Promise < void > {
46
45
const p = currentFlushPromise || resolvedPromise
47
46
return fn ? p . then ( this ? fn . bind ( this ) : fn ) : p
Original file line number Diff line number Diff line change @@ -905,6 +905,25 @@ describe('emits', () => {
905
905
expectError ( this . $emit ( 'input' ) )
906
906
// @ts -expect-error
907
907
expectError ( this . $emit ( 'input' , 1 ) )
908
+ } ,
909
+ mounted ( ) {
910
+ // #3599
911
+ this . $nextTick ( function ( ) {
912
+ // this should be bound to this instance
913
+
914
+ this . $emit ( 'click' , 1 )
915
+ this . $emit ( 'input' , 'foo' )
916
+ // @ts -expect-error
917
+ expectError ( this . $emit ( 'nope' ) )
918
+ // @ts -expect-error
919
+ expectError ( this . $emit ( 'click' ) )
920
+ // @ts -expect-error
921
+ expectError ( this . $emit ( 'click' , 'foo' ) )
922
+ // @ts -expect-error
923
+ expectError ( this . $emit ( 'input' ) )
924
+ // @ts -expect-error
925
+ expectError ( this . $emit ( 'input' , 1 ) )
926
+ } )
908
927
}
909
928
} )
910
929
You can’t perform that action at this time.
0 commit comments