[🐞] `useDebouncer$` from docs has broken types
Describe the bug
in qwik's docs there is a page that generously shares code for a useDebouncer$ hook that works fine, but has broken type definitions, causing it to break the application in the moment of build
here is the debouncer code:
export const useDebouncerQrl = <A extends readonly unknown[], R>(
fn: QRL<(...args: A) => R>,
delay: number,
): QRL<(...args: A) => void> => {
const timeoutId = useSignal<number>();
return $((...args: A): void => {
window.clearTimeout(timeoutId.value);
timeoutId.value = window.setTimeout((): void => {
void fn(...args);
}, delay);
});
};
export const useDebouncer$ = implicit$FirstArg(useDebouncerQrl);
it throws the following error in the void fn(...args); line:
Argument of type '[...A]' is not assignable to parameter of type 'QrlArgs<(...args: A) => R>'.
as I'm not a typescript lord I'd really like somebody else's help to solve this issue
Reproduction
https://qwik.dev/examples/introduction/hello-world/#f=7VZNS8NAEL37K0YoZIVl6UWRxQZ68dRLcxUPhTQS1A0krSDS%2F%2B6bnf0iVuhVMKd8zdvZmX3vTXFo7u%2FOHhrNHgtK94fFYz9Oh%2FWIviVD1oQffBe3zeaS8yX1YJ4FlR%2B3MLsV0oXGgIQtK96uHdzbJx3dK3zNPT1ramouVecsr%2FOgjDGs65bWvqJNrfHVC5INvqOvbs7%2F%2BzH0bR3bINlkk10Vo4bg1AqFotwx0KEAtB4uohGMgKlsSvFTCd1AMo57hsM1e4uVQ2w2WRBvjk%2Fy3LmYREA7adm9f2QuorX0e8kXWO5HV9WsKUC5SBQEPvn4ZniRMubVlHrfTxMk24YxMMVKdBzSqhjSUgyodLyVrWm6XS45szmFeDpNRPATamJCGtC%2BctLxKtNWlTBt12FoSl%2Buq1BjX%2BdTuM0889hIMhNN5uNAtZAXt%2BRfIv%2BkRH4D
Steps to reproduce
System Info
@patrickkmatias /shaliah (feat-persist-state-serverside) > npx envinfo --system --npmPackages '{vite,undici,typescript,@builder.io/*}' --binaries --browsers
Need to install the following packages:
[email protected]
Ok to proceed? (y) y
System:
OS: Linux 6.11 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
Memory: 1.13 GB / 7.11 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 22.14.0 - /usr/local/bin/node
npm: 11.2.0 - /usr/local/bin/npm
Browsers:
Chrome: 135.0.7049.114
npmPackages:
typescript: 5.4.5 => 5.4.5
undici: * => 7.8.0
Additional Information
No response
very odd, it infers the wrong type for fn. Looks like it's unhappy about how QRL is defined, somehow.
This may need redefining QRL