[🐞] `useDebouncer$` from docs has broken types
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 22.1k
- Forks
- 1.4k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
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:
envinfo@7.14.0
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the useDebouncer$ snippet on the linked Qwik cookbook page and reproduce the TypeScript build error in the linked example. Check the reported void fn(...args) type failure; it is done when the documented snippet builds successfully with the debouncer behavior intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100