From cb2416042cea89419928aa21caf97de0edcc11e5 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Sun, 5 May 2024 09:37:29 +0900 Subject: [PATCH] fix(types): relax the type of `c.req.param()` (#2613) * fix(types): relax the type of `c.req.param()` * denoify --- deno_dist/request.ts | 1 + src/hono.test.ts | 2 -- src/request.ts | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deno_dist/request.ts b/deno_dist/request.ts index 4d353a00b..ea1825379 100644 --- a/deno_dist/request.ts +++ b/deno_dist/request.ts @@ -79,6 +79,7 @@ export class HonoRequest

{ param> = RemoveQuestion>>( key: P2 ): string | undefined + param(key: string): string | undefined param(): UnionToIntersection>> param(key?: string): unknown { return key ? this.getDecodedParam(key) : this.getAllDecodedParams() diff --git a/src/hono.test.ts b/src/hono.test.ts index 02429274f..3a79dac82 100644 --- a/src/hono.test.ts +++ b/src/hono.test.ts @@ -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 }) }) diff --git a/src/request.ts b/src/request.ts index fa748c5f1..b5fd8546e 100644 --- a/src/request.ts +++ b/src/request.ts @@ -79,6 +79,7 @@ export class HonoRequest

{ param> = RemoveQuestion>>( key: P2 ): string | undefined + param(key: string): string | undefined param(): UnionToIntersection>> param(key?: string): unknown { return key ? this.getDecodedParam(key) : this.getAllDecodedParams()