Repository navigation
Conversation
`RouteUrl` allowed a suffix only after a route path, so adding `?page=2` to a `routeUrl()` result failed the type check. Apply the suffix to a shared base instead, in both the runtime and the generated declaration.
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.
Fixes #893
Description
RouteUrlaccepted a query or hash suffix only after a route path, so appending?page=2to arouteUrl()result dropped out ofRouteUrl.router.visit(),Link, and props typedRouteUrlrejected it, and Void 1.9.1 accepted the same code.The suffix now applies to a shared base,
BuiltRouteUrl | RoutePathUrl, in the runtime type and in the declarationvoid preparewrites. Both spellings of a route URL take the same suffix, so the union has one place to change.A suffix on a
routeUrl()result that already carriesqueryorhashstill type-checks, as in the issue's${routeUrl('/a', { query: { a: 1 } })}?b=2.BuiltRouteUrlis opaque, so telling that apart needs a second brand. Route path strings already allow the same join.Test
The typed fixture in
route-url-builder.test.tsnow appends a query and a hash to aRouteUrl, to arouteUrl()result, and passes both torouter.visit(). It also pins that a suffix does not skip the route check (/unknown?page=2) and that it needs its own separator.With the same fixture on the base types: