Skip to content

Commit

Permalink
fix(types): relax the type of c.req.param() (honojs#2613)
Browse files Browse the repository at this point in the history
* fix(types): relax the type of `c.req.param()`

* denoify
  • Loading branch information
yusukebe authored May 5, 2024
1 parent a900fbe commit cb24160
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions deno_dist/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class HonoRequest<P extends string = '/', I extends Input['out'] = {}> {
param<P2 extends RemoveQuestion<ParamKeys<P>> = RemoveQuestion<ParamKeys<P>>>(
key: P2
): string | undefined
param(key: string): string | undefined
param<P2 extends string = P>(): UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>
param(key?: string): unknown {
return key ? this.getDecodedParam(key) : this.getAllDecodedParams()
Expand Down
2 changes: 0 additions & 2 deletions src/hono.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,6 @@ describe('param and query', () => {
describe('param with undefined', () => {
const app = new Hono()
app.get('/foo/:foo', (c) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
/* @ts-ignore */
const bar = c.req.param('bar')
return c.json({ foo: bar })
})
Expand Down
1 change: 1 addition & 0 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class HonoRequest<P extends string = '/', I extends Input['out'] = {}> {
param<P2 extends RemoveQuestion<ParamKeys<P>> = RemoveQuestion<ParamKeys<P>>>(
key: P2
): string | undefined
param(key: string): string | undefined
param<P2 extends string = P>(): UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>
param(key?: string): unknown {
return key ? this.getDecodedParam(key) : this.getAllDecodedParams()
Expand Down

0 comments on commit cb24160

Please sign in to comment.