Skip to content

Conversation

@yash-dayama
Copy link

Fixes #3566

Updated typedef of interface Route from:
query: Dictionary<string | (string | null)[]>
to:
query: Dictionary<string | null | (string | null)[]>

Changes made:

  1. Updated TypeScript type definition to properly handle null values in query parameters
  2. Updated Flow type definitions to match the TypeScript changes
  3. Added dedicated type tests in types/test/query-types.test.ts that verify:
    • String values (?foo=bar)
    • Null values (?foo)
    • Array values (?foo=bar&foo=baz)
    • Mixed arrays with both strings and nulls

This change ensures proper typing for query parameters that don't have any value, while maintaining backward compatibility.

@netlify
Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for vue-router-docs-v3 canceled.

Name Link
🔨 Latest commit c49c3dc
🔍 Latest deploy log https://app.netlify.com/projects/vue-router-docs-v3/deploys/688b042be3a47d00082e6847
@yash-dayama yash-dayama force-pushed the fix/route-query-type-3566 branch 3 times, most recently from 946af17 to 3a5a7f2 Compare July 31, 2025 05:42
- Updated TypeScript and Flow type definitions to properly handle null values in query parameters - Added dedicated type tests to verify query parameter scenarios Fixes vuejs#3566
@yash-dayama yash-dayama force-pushed the fix/route-query-type-3566 branch from 3a5a7f2 to c49c3dc Compare July 31, 2025 05:50
@yash-dayama
Copy link
Author

After 3 retries here is what I have done @posva can you please have a look

Fixed the Route query type definition issue with the following changes: 1. Type Definitions: - Updated Route interface query type to properly handle null values: ```ts query: Dictionary<string | null | (string | null)[]> ``` - Added QueryValue and QueryDictionary types in Flow for better type organization - Added dedicated type tests in types/test/query-types.test.ts 2. Runtime Changes: - Improved isObjectEqual to properly handle array comparisons and string conversions - Updated resolveQuery and stringifyQuery to use QueryDictionary type - Fixed query type handling in normalizeLocation These changes ensure proper typing for all query parameter scenarios: - String values (?foo=bar) - Null values (?foo) - Array values (?foo=bar&foo=baz) - Mixed arrays with both strings and nulls All tests are passing and Flow type checking is successful. This maintains backward compatibility while fixing the type definition issues reported in #3566. 
@posva
Copy link
Member

posva commented Jul 31, 2025

Thanks but same as in the other PR 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants