reverse type param ordering
Throughout the codebase, type param ordering places P (the parsed param object, inferred from the route path literal) before S (library-consumer-declared state). This is ordering is not preferable, as it does not allow one to explicitly type S while still inferring P.
For instance, let's consider the following example:
const SOME_PATH = "/x/:hi/:there"
const handler: RouterMiddleware<typeof SOME_PATH> = (ctx) => {
ctx.params // { hi: string; there: string; }
}
If I want to specify a type for state, I'd need to do the following:
- const handler: RouterMiddleware<typeof SOME_PATH> = (ctx) => {
+ const handler: RouterMiddleware<typeof SOME_PATH, RouteParams<typeof SOME_PATH>, MyStateType> = (ctx) => {}
By reversing the type param order, we can simplify.
- const handler: RouterMiddleware<typeof SOME_PATH> = (ctx) => {
+ const handler: RouterMiddleware<typeof SOME_PATH, MyStateType> = (ctx) => {}
Please let me know if this change is desirable and––if so––what else needs to come into place. I needed to disable a few type type tests which were failing (would be great to hear maintainer thoughts on those failures).
Could someone please take a look at this PR?
Kindly pinging @kitsonk for thoughts/guidance.