Open
Description
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
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