Repository navigation
Conversation
cpojer
requested changes
Nov 17, 2026
cpojer
left a comment
Member
There was a problem hiding this comment.
Three issues, here is some slop:
- Generic helpers stop compiling. A helper whose
idisT extends string | numbercan no longer callrouteUrl('/users/[id]', { params: { id } }). Forwarding typed options also breaks. Preserve the valid-call signature while adding diagnostic fallbacks. Signature- Valid objects with additional fields are rejected. Passing
const user = { id: 42, name: 'Alice' }as params now errors onname; passing aRouteDestinationas options also fails. These previously compiled and work at runtime. Preserve structural assignability. Validation- Invalid inputs can now bypass validation. A query typed
{ q: string } | { filter: { id: number } }compiles and serializes the object as[object Object]. Numeric param keys can also hide a missing requiredid, producing a runtime exception. Validate every union branch and avoid dropping numeric keys. Error calculation
Collaborator
Author
|
Thanks I'll look into them. |
yangshun
marked this pull request as draft
November 17, 2026 03:14
yangshun
marked this pull request as ready for review
November 17, 2026 04:18
yangshun
marked this pull request as draft
November 17, 2026 04:40
Member
|
Some more issues as these calls compile now but throw at runtime: const userUrl = routeUrl.bind(undefined, '/users/[id]');
userUrl(); // Missing required id
userUrl({ params: { id: true } }); // Invalid id type
function forward(...args: Parameters<typeof routeUrl>) {
return routeUrl(...args);
} |
Collaborator
Author
|
Thanks, doing more rounds of reviews and need to do more thorough testing |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
While using
typedRoutes: true, I found that invalidrouteUrl()produced non-helpful messages, like misleading argument-count errors or generic type mismatches.This change adds diagnostics that identify the route, explain the problem, and suggest a correction.
Given
/aboutand/users/[id], the relevant diagnostic excerpts change as follows:routeUrl('/missing')routeUrl('/users/[id]'){ params: { ... } }.routeUrl('/users/[id]', { params: { userId: 42 } })routeUrl('/users/[id]', { params: { id: true } })routeUrl('/about', { params: { id: 42 } })Also adds explanations for invalid query values, hash values, unknown options, and unchecked strings. Both generated and packaged declarations use the improved diagnostics, while preserving route/parameter autocomplete and required-parameter checks.
Valid calls retain the original argument types, including generic helpers, forwarding with a generic route path, and structural objects with additional fields. Generated URL declarations reference the SDK's canonical types through a stable internal types-only export, so SDK upgrades preserve route checking without regenerating
.void/routes.d.ts. Reusable diagnostic helpers live in a private module. This prepares the shared types for a separate PR improving raw URL diagnostics.Validation:
Parameters<typeof routeUrl<P>>for generic route paths. All 30 invalid-call probes remain rejected in TypeScript 6 and 7 through both declaration paths.skipLibCheck: true.@voidzero-dev/vite-plus-core@8.3.8000while the unchanged scaffold installs1.6.0. Failed job.