From: Yang Mingshan Date: Tue, 2 Sep 2025 09:13:08 +0000 (+0800) Subject: chore(types): compatible with TS 5.8 (#12973) X-Git-Tag: v3.5.21~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4810f1489fd3b311eac0265e8f2607fd0cbcbfb4;p=thirdparty%2Fvuejs%2Fcore.git chore(types): compatible with TS 5.8 (#12973) --- diff --git a/packages-private/dts-test/scheduler.test-d.ts b/packages-private/dts-test/scheduler.test-d.ts new file mode 100644 index 000000000..26702432b --- /dev/null +++ b/packages-private/dts-test/scheduler.test-d.ts @@ -0,0 +1,31 @@ +import { nextTick } from 'vue' +import { describe, expectType } from './utils' + +describe('nextTick', async () => { + expectType>(nextTick()) + expectType>(nextTick(() => 'foo')) + expectType>(nextTick(() => Promise.resolve('foo'))) + expectType>( + nextTick(() => Promise.resolve(Promise.resolve('foo'))), + ) + + expectType(await nextTick()) + expectType(await nextTick(() => 'foo')) + expectType(await nextTick(() => Promise.resolve('foo'))) + expectType( + await nextTick(() => Promise.resolve(Promise.resolve('foo'))), + ) + + nextTick().then(value => { + expectType(value) + }) + nextTick(() => 'foo').then(value => { + expectType(value) + }) + nextTick(() => Promise.resolve('foo')).then(value => { + expectType(value) + }) + nextTick(() => Promise.resolve(Promise.resolve('foo'))).then(value => { + expectType(value) + }) +}) diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 59b713dd8..024629701 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -275,7 +275,7 @@ export function proxyRefs( objectWithRefs: T, ): ShallowUnwrapRef { return isReactive(objectWithRefs) - ? objectWithRefs + ? (objectWithRefs as ShallowUnwrapRef) : new Proxy(objectWithRefs, shallowUnwrapHandlers) } diff --git a/packages/runtime-core/src/scheduler.ts b/packages/runtime-core/src/scheduler.ts index b40c31d39..af6752078 100644 --- a/packages/runtime-core/src/scheduler.ts +++ b/packages/runtime-core/src/scheduler.ts @@ -53,10 +53,15 @@ let currentFlushPromise: Promise | null = null const RECURSION_LIMIT = 100 type CountMap = Map -export function nextTick( +export function nextTick(): Promise +export function nextTick( this: T, - fn?: (this: T) => R, -): Promise> { + fn: (this: T) => R | Promise, +): Promise +export function nextTick( + this: T, + fn?: (this: T) => R | Promise, +): Promise { const p = currentFlushPromise || resolvedPromise return fn ? p.then(this ? fn.bind(this) : fn) : p }