File tree Expand file tree Collapse file tree 3 files changed +40
-4
lines changed
packages-private/dts-test Expand file tree Collapse file tree 3 files changed +40
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { nextTick } from 'vue'
2
+ import { describe , expectType } from './utils'
3
+
4
+ describe ( 'nextTick' , async ( ) => {
5
+ expectType < Promise < void > > ( nextTick ( ) )
6
+ expectType < Promise < string > > ( nextTick ( ( ) => 'foo' ) )
7
+ expectType < Promise < string > > ( nextTick ( ( ) => Promise . resolve ( 'foo' ) ) )
8
+ expectType < Promise < string > > (
9
+ nextTick ( ( ) => Promise . resolve ( Promise . resolve ( 'foo' ) ) ) ,
10
+ )
11
+
12
+ expectType < void > ( await nextTick ( ) )
13
+ expectType < string > ( await nextTick ( ( ) => 'foo' ) )
14
+ expectType < string > ( await nextTick ( ( ) => Promise . resolve ( 'foo' ) ) )
15
+ expectType < string > (
16
+ await nextTick ( ( ) => Promise . resolve ( Promise . resolve ( 'foo' ) ) ) ,
17
+ )
18
+
19
+ nextTick ( ) . then ( value => {
20
+ expectType < void > ( value )
21
+ } )
22
+ nextTick ( ( ) => 'foo' ) . then ( value => {
23
+ expectType < string > ( value )
24
+ } )
25
+ nextTick ( ( ) => Promise . resolve ( 'foo' ) ) . then ( value => {
26
+ expectType < string > ( value )
27
+ } )
28
+ nextTick ( ( ) => Promise . resolve ( Promise . resolve ( 'foo' ) ) ) . then ( value => {
29
+ expectType < string > ( value )
30
+ } )
31
+ } )
Original file line number Diff line number Diff line change @@ -275,7 +275,7 @@ export function proxyRefs<T extends object>(
275
275
objectWithRefs : T ,
276
276
) : ShallowUnwrapRef < T > {
277
277
return isReactive ( objectWithRefs )
278
- ? objectWithRefs
278
+ ? ( objectWithRefs as ShallowUnwrapRef < T > )
279
279
: new Proxy ( objectWithRefs , shallowUnwrapHandlers )
280
280
}
281
281
Original file line number Diff line number Diff line change @@ -53,10 +53,15 @@ let currentFlushPromise: Promise<void> | null = null
53
53
const RECURSION_LIMIT = 100
54
54
type CountMap = Map < SchedulerJob , number >
55
55
56
- export function nextTick < T = void , R = void > (
56
+ export function nextTick ( ) : Promise < void >
57
+ export function nextTick < T , R > (
57
58
this : T ,
58
- fn ?: ( this : T ) => R ,
59
- ) : Promise < Awaited < R > > {
59
+ fn : ( this : T ) => R | Promise < R > ,
60
+ ) : Promise < R >
61
+ export function nextTick < T , R > (
62
+ this : T ,
63
+ fn ?: ( this : T ) => R | Promise < R > ,
64
+ ) : Promise < void | R > {
60
65
const p = currentFlushPromise || resolvedPromise
61
66
return fn ? p . then ( this ? fn . bind ( this ) : fn ) : p
62
67
}
You can’t perform that action at this time.
0 commit comments