fix(request): return `string | undefined` from param() when path type is any (#4723)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* fix: return string | undefined from param() when path type is any When middleware uses Context with a default path type parameter (any), c.req.param('key') incorrectly returns string instead of string | undefined. This is because ParamKeys<any> resolves to string, matching the first overload that returns string. Add a new overload that detects when P is any using the 0 extends (1 & P) trick and returns string | undefined, ensuring type safety in middleware. Fixes #3198 * ci: apply automated fixes * test(request): add type tests for param() with any path type * fixed the overload and test ---------
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: exe.dev user <exedev@queen-xray.exe.xyz>
- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Co-authored-by: andrewdamelio <andrewdamelio@gmail.com>
- Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
Diff stats
3 files+25 added−2 removed
- tests:+22 added−1 removed
- other:+3 added−1 removed