Skip to content

fix: ExtractRouteParams<string> rejecting array query values#8

Open
antoinekm wants to merge 1 commit intoalii:masterfrom
antoinekm:fix/extract-route-params-string-fallback
Open

fix: ExtractRouteParams<string> rejecting array query values#8
antoinekm wants to merge 1 commit intoalii:masterfrom
antoinekm:fix/extract-route-params-string-fallback

Conversation

@antoinekm
Copy link
Copy Markdown
Contributor

Problem

When using pathcat with a path that has no route params (e.g. /stream), Query<string> does not accept array values despite QueryValue supporting them.

const params: Query<string> = { events: ['a', 'b'] };
// Error: Type 'string[]' is not assignable to type 'ParamValue'

Cause

ExtractRouteParams<string> resolves to string (the catch-all branch), making Query<string> become Record<string, ParamValue> & Record<string, QueryValue>. The intersection collapses to Record<string, ParamValue>, eliminating arrays.

Fix

  • Change ExtractRouteParams<string> fallback from string to never so Query<string> becomes Record<never, ParamValue> & Record<string, QueryValue> = Record<string, QueryValue>
  • Guard the route-param replacement against arrays to keep paramValueToString type-safe

All 23 existing tests pass unchanged.

Closes #7

When T is a bare `string`, ExtractRouteParams resolved to `string`,
causing Query<string> to collapse arrays out of the intersection.
Changing the fallback to `never` keeps QueryValue (incl. arrays)
reachable for every key.

Also guard the route-param replacement branch against arrays so the
internal `paramValueToString` call stays type-safe.

Closes alii#7
@alii
Copy link
Copy Markdown
Owner

alii commented Apr 11, 2026

Thank you! I'll look at this today

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.

Query<string> type rejects arrays for paths without route params

2 participants