From 03952f3718a5cba9711cdca40af3ddf0a53bbc88 Mon Sep 17 00:00:00 2001 From: axuj Date: Mon, 24 Aug 2026 12:03:52 +0800 Subject: [PATCH] fix(types): move timer declarations into declare-global so bare calls resolve them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit common/global.d.ts is a module (it imports SystemInfo et al.), and the four bare 'declare function' timer declarations sat OUTSIDE its declare-global block. Module-scoped declarations are private: bare-global call sites in application code never resolved to them — every ReactLynx/Rspeedy project silently fell back to @types/node or DOM signatures instead, which accept forwarded extra args that Lynx host timers actually drop (js_app.cc / napi_lepus_lynx.cc fire the callback zero-arg), so forwarded calls pass typecheck yet break on device. Move the four declarations inside declare-global (signature unchanged, misleading parameter name 'number' renamed to 'delay') and document the two-arg contract. --- js_libraries/types/types/common/global.d.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js_libraries/types/types/common/global.d.ts b/js_libraries/types/types/common/global.d.ts index 80964b0ece..1818ea9187 100644 --- a/js_libraries/types/types/common/global.d.ts +++ b/js_libraries/types/types/common/global.d.ts @@ -46,9 +46,12 @@ declare global { function cancelAnimationFrame(requestID?: number): void; function getNapiLoader(): LynxNapiLoader | undefined; -} -declare function setTimeout(callback: (...args: unknown[]) => unknown, number: number): number; -declare function setInterval(callback: (...args: unknown[]) => unknown, number: number): number; -declare function clearTimeout(timeoutId: number): void; -declare function clearInterval(timeoutId: number): void; + function setTimeout(callback: (...args: unknown[]) => unknown, delay?: number): number; + + function setInterval(callback: (...args: unknown[]) => unknown, delay?: number): number; + + function clearTimeout(timeoutId: number): void; + + function clearInterval(intervalId: number): void; +}