We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Express.js again with TypeScript we noticed it's able to auto-complete the path param property names on requests based on the defined route.
Example:
This appears to be achieved using type definitions like the example below from @types/express.
// prettier-ignore export type RouteParameters<Route extends string> = string extends Route ? ParamsDictionary : Route extends `${string}(${string}` ? ParamsDictionary //TODO: handling for regex parameters : Route extends `${string}:${infer Rest}` ? ( GetRouteParameter<Rest> extends never ? ParamsDictionary : GetRouteParameter<Rest> extends `${infer ParamName}?` ? { [P in ParamName]?: string } : { [P in GetRouteParameter<Rest>]: string } ) & (Rest extends `${GetRouteParameter<Rest>}${infer Next}` ? RouteParameters<Next> : unknown) : {};
Let's try to implement something equivalent in our ctx.req object.
Reduce typos and improve the type safety of the params object.
The current solution of retrieving values like this ctx.req.params["pathparam"]
ctx.req.params["pathparam"]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Feature Request
Suggestion
Using Express.js again with TypeScript we noticed it's able to auto-complete the path param property names on requests based on the defined route.
Example:

This appears to be achieved using type definitions like the example below from @types/express.
Let's try to implement something equivalent in our ctx.req object.
Value
Reduce typos and improve the type safety of the params object.
Alternatives
The current solution of retrieving values like this
ctx.req.params["pathparam"]
The text was updated successfully, but these errors were encountered: