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>(
275275 objectWithRefs : T ,
276276) : ShallowUnwrapRef < T > {
277277 return isReactive ( objectWithRefs )
278- ? objectWithRefs
278+ ? ( objectWithRefs as ShallowUnwrapRef < T > )
279279 : new Proxy ( objectWithRefs , shallowUnwrapHandlers )
280280}
281281
Original file line number Diff line number Diff line change @@ -53,10 +53,15 @@ let currentFlushPromise: Promise<void> | null = null
5353const RECURSION_LIMIT = 100
5454type CountMap = Map < SchedulerJob , number >
5555
56- export function nextTick < T = void , R = void > (
56+ export function nextTick ( ) : Promise < void >
57+ export function nextTick < T , R > (
5758 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 > {
6065 const p = currentFlushPromise || resolvedPromise
6166 return fn ? p . then ( this ? fn . bind ( this ) : fn ) : p
6267}
You can’t perform that action at this time.
0 commit comments