types: compatible with TS 5.8

This commit is contained in:
Yang Mingshan 2025-03-02 00:00:15 +08:00
parent 8bd9cdb77e
commit 3fdd1c4242
4 changed files with 15 additions and 8 deletions

View File

@ -263,7 +263,7 @@ export function processFor(
dir: DirectiveNode, dir: DirectiveNode,
context: TransformContext, context: TransformContext,
processCodegen?: (forNode: ForNode) => (() => void) | undefined, processCodegen?: (forNode: ForNode) => (() => void) | undefined,
) { ): (() => void) | undefined {
if (!dir.exp) { if (!dir.exp) {
context.onError( context.onError(
createCompilerError(ErrorCodes.X_V_FOR_NO_EXPRESSION, dir.loc), createCompilerError(ErrorCodes.X_V_FOR_NO_EXPRESSION, dir.loc),

View File

@ -114,7 +114,7 @@ export function processDefineModel(
return true return true
} }
export function genModelProps(ctx: ScriptCompileContext) { export function genModelProps(ctx: ScriptCompileContext): string | undefined {
if (!ctx.hasDefineModelCall) return if (!ctx.hasDefineModelCall) return
const isProd = !!ctx.options.isProd const isProd = !!ctx.options.isProd

View File

@ -275,7 +275,7 @@ export function proxyRefs<T extends object>(
objectWithRefs: T, objectWithRefs: T,
): ShallowUnwrapRef<T> { ): ShallowUnwrapRef<T> {
return isReactive(objectWithRefs) return isReactive(objectWithRefs)
? objectWithRefs ? (objectWithRefs as any)
: new Proxy(objectWithRefs, shallowUnwrapHandlers) : new Proxy(objectWithRefs, shallowUnwrapHandlers)
} }

View File

@ -47,16 +47,21 @@ const pendingPostFlushCbs: SchedulerJob[] = []
let activePostFlushCbs: SchedulerJob[] | null = null let activePostFlushCbs: SchedulerJob[] | null = null
let postFlushIndex = 0 let postFlushIndex = 0
const resolvedPromise = /*@__PURE__*/ Promise.resolve() as Promise<any> const resolvedPromise = /*@__PURE__*/ Promise.resolve()
let currentFlushPromise: Promise<void> | null = null let currentFlushPromise: Promise<void> | null = null
const RECURSION_LIMIT = 100 const RECURSION_LIMIT = 100
type CountMap = Map<SchedulerJob, number> type CountMap = Map<SchedulerJob, number>
export function nextTick<T = void, R = void>( export function nextTick(): Promise<void>
export function nextTick<T, R>(
this: T, this: T,
fn?: (this: T) => R, fn: (this: T) => R | Promise<R>,
): Promise<Awaited<R>> { ): Promise<R>
export function nextTick<T, R>(
this: T,
fn?: (this: T) => R | Promise<R>,
): Promise<void | R> {
const p = currentFlushPromise || resolvedPromise const p = currentFlushPromise || resolvedPromise
return fn ? p.then(this ? fn.bind(this) : fn) : p return fn ? p.then(this ? fn.bind(this) : fn) : p
} }
@ -113,7 +118,9 @@ export function queueJob(job: SchedulerJob): void {
function queueFlush() { function queueFlush() {
if (!currentFlushPromise) { if (!currentFlushPromise) {
currentFlushPromise = resolvedPromise.then(flushJobs) currentFlushPromise = resolvedPromise.then(() => {
flushJobs()
})
} }
} }