Open ghost opened 2 months ago
Right now the typing for URL pattern component result groups is basically just Record<string, string | undefined>.
Record<string, string | undefined>
However, take a look at this: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d182347b9be493cd37ad26a0b7a8285310cc914/types/express-serve-static-core/index.d.ts#L108
You can see it is able to infer the correct params based on a string.
For example:
const pathname = "/about/:name/:age?"; const props = async (groups: RouteParameters<typeof pathname>) => { return { name: groups.name }; };
It infers the types perfectly, and works with optional params, and infinite params:
(parameter) groups: { name: string; } & { age?: string | undefined; }
For now I have added this package to my project, but it would be nice if this lib implemented the same typing for groups.
groups
Right now the typing for URL pattern component result groups is basically just
Record<string, string | undefined>
.However, take a look at this: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d182347b9be493cd37ad26a0b7a8285310cc914/types/express-serve-static-core/index.d.ts#L108
You can see it is able to infer the correct params based on a string.
For example:
It infers the types perfectly, and works with optional params, and infinite params:
For now I have added this package to my project, but it would be nice if this lib implemented the same typing for
groups
.