Skip to content

docs: fix up cookbook debounce typing #7643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025
Merged

Conversation

extrordinaire
Copy link
Contributor

@extrordinaire extrordinaire commented May 26, 2025

What is it?

  • Docs / tests / types / typos

Description

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.

Tested on TypeScript 5.4.5

Checklist

  • I made corresponding changes to the Qwik docs

## 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.
@extrordinaire extrordinaire requested a review from a team as a code owner May 26, 2025 17:21
Copy link

changeset-bot bot commented May 26, 2025

⚠️ No Changeset found

Latest commit: 677a5bf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your help @extrordinaire

@gioboa gioboa enabled auto-merge (squash) May 26, 2025 19:55
@gioboa gioboa changed the title Docs/Cookbook/Debounce Adjust tuple typing to comply with QrlArgs expectations docs: fix up cookbook debounce typing May 26, 2025
@gioboa gioboa disabled auto-merge May 26, 2025 19:56
@gioboa gioboa enabled auto-merge (squash) May 26, 2025 19:57
Copy link
Contributor

github-actions bot commented May 26, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 677a5bf

Copy link
Member

@wmertens wmertens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🦎

@gioboa gioboa merged commit 83467ca into QwikDev:main Jun 2, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants