Skip to content

Commit 83467ca

Browse files
docs: fix up cookbook debounce typing (#7643)
Update index.mdx ## Summary This PR addresses a TypeScript error related to the use of readonly tuple types in conjunction with QRL. ## Problem Using a readonly tuple type A extends readonly unknown[] caused the following TypeScript diagnostic when invoking a QRL: Argument of type '[...A]' is not assignable to parameter of type 'QrlArgs<(...args: A) => R>'. [2345] ## Root Cause This appears to be a type compatibility issue between the readonly tuple spread ([...A]) and the expected QrlArgs type in the QRL function signature. It's possible there's an edge case or mismatch in how QrlArgs<(...args: A) => R> resolves in the presence of readonly tuples, or perhaps recent TypeScript updates introduced stricter rules around readonly spreads. ## Solution The fix involves removing the readonly modifier from the generic tuple constraint: - A extends readonly unknown[] + A extends unknown[] This ensures compatibility with the QRL's expected argument types while preserving type safety. ### Notes Further investigation might be warranted to confirm whether this is a TypeScript typing nuance or a limitation in the Qwik QRL typings themselves.
1 parent a44097c commit 83467ca

File tree

1 file changed

+2
-2
lines changed
  • packages/docs/src/routes/docs/cookbook/debouncer

1 file changed

+2
-2
lines changed

packages/docs/src/routes/docs/cookbook/debouncer/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The Qwik framework provides unique capabilities for managing state and effects i
3131

3232
<CodeFile src="/src/routes/demo/cookbook/mediaController/index.tsx">
3333
```tsx
34-
export const useDebouncer = <A extends readonly unknown[], R>(
34+
export const useDebouncer = <A extends unknown[], R>(
3535
fn: QRL<(...args: A) => R>,
3636
delay: number,
3737
): QRL<(...args: A) => void> => {
@@ -98,7 +98,7 @@ We can leverage Qwik's `implicit$FirstArg` function to create a `useDebouncer$`
9898
This is how Qwik actually implements all of its built-in $ hooks.
9999

100100
```tsx
101-
export const useDebouncerQrl = <A extends readonly unknown[], R>(
101+
export const useDebouncerQrl = <A extends unknown[], R>(
102102
fn: QRL<(...args: A) => R>,
103103
delay: number,
104104
): QRL<(...args: A) => void> => {

0 commit comments

Comments
 (0)