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 |
yangshun
force-pushed
the
codex/improve-route-url-diagnostics
branch
from
November 17, 2026 06:50
371053e to
7e24fec
Compare
yangshun
marked this pull request as ready for review
November 17, 2026 10:47
Collaborator
Author
|
EDIT: Not yet ready. Overzealous AI went to mark it as ready and anyhow wrote a bunch of comments. |
yangshun
marked this pull request as draft
November 17, 2026 11:01
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.
Problem and behavior
With
typedRoutes: true, an unknown route or a route called without its required options can produce a misleading argument-count error. This adds custom guidance for those cases and for unchecked string paths. Known routes with options retain TypeScript's native property and value errors, which show the required types directly.Given
/aboutand/users/[id], the relevant diagnostic excerpts change as follows:routeUrl('/missing')routeUrl('/users/[id]')Known-route option errors remain native. For example:
The public
routeUrl(path, options)API and valid-call contract are preserved, including generic helpers, structural objects with extra fields, and specialized or unspecializedParametersforwarding.Parameters,.bind(),.call(), and.apply()keep the checked signature, and explicit route type arguments remain constrained to registered patterns. Route, option, and param autocomplete remain intact.Generated URL declarations reference the installed SDK's canonical types through the stable
void/_route-url-typesexport, including under legacy Node module resolution. This lets SDK type updates take effect without regenerating.void/routes.d.ts. The export's compatibility requirement is documented in the package maintainer guidance.TypeScript's overload heading remains for calls with options. Generic path-only calls can still produce verbose conditional-type diagnostics. Raw URL diagnostics remain for a separate PR.
Validation
params/query/hashfor options, and the correct param names.skipLibCheckon or off. Upgrade regressions change the installed SDK query contract and remove the old installation while keeping generated declarations unchanged.The ad-hoc diagnostics playground and its generated reports are gitignored and are not included in this PR.