Skip to content

Conversation

@DamienW-dev
Copy link

This PR provides a complementary fix to PR #106 to ensure full compatibility with
TypeScript strict mode (including vue-tsc and isolatedModules).

PR #106 already improves nested query parameter handling, but the generated
queryParams function still triggers TypeScript strict errors such as:

  • TS2533: Object is possibly 'null' or 'undefined'
  • TS2339: Property 'forEach' does not exist on type 'string | number | boolean | array | QueryParams'
  • TS7006: Parameter implicitly has an 'any' type
  • TS2345: Argument of type 'undefined' not assignable
  • TS7053: Element implicitly has an 'any' type because of union indexing

These errors appear because QueryParams is a recursive union type, and TypeScript
requires explicit narrowing before indexing or branching on values.

✔ What this PR fixes

  • Adds explicit type narrowing before accessing union members
  • Ensures all branches are fully type-safe
  • Removes all remaining strict-mode errors
  • Does not change runtime behavior
  • Keeps the original QueryParams type unchanged
  • Compatible with the logic introduced in PR Fix: support nested query parameters with multi-level depth #106

✔ Why this matters

Wayfinder generates .ts files that are imported into other generated files via
relative imports.
Because of that, developers cannot exclude the generated file from TypeScript
compilation
, and strict mode compilation fails.

This fix ensures Wayfinder works out-of-the-box in modern TS setups.

🔗 Related

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.

2 participants