From 52a9f1f13bb9ddbee7eb59841b49254906b82c56 Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Fri, 24 May 2024 17:47:37 +0900 Subject: [PATCH 1/2] refactor(request): show user-friendly type for `c.req.param()` --- src/request.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/request.ts b/src/request.ts index 7c028aee5..fcf7b9f6e 100644 --- a/src/request.ts +++ b/src/request.ts @@ -11,7 +11,7 @@ import type { } from './types' import { parseBody } from './utils/body' import type { BodyData, ParseBodyOptions } from './utils/body' -import type { UnionToIntersection } from './utils/types' +import type { Simplify, UnionToIntersection } from './utils/types' import { getQueryParam, getQueryParams, decodeURIComponent_ } from './utils/url' type Body = { @@ -80,7 +80,7 @@ export class HonoRequest

{ key: P2 ): string | undefined param(key: string): string | undefined - param(): UnionToIntersection>> + param(): Simplify>>> param(key?: string): unknown { return key ? this.getDecodedParam(key) : this.getAllDecodedParams() } From 79357f61c72ef9a4c1986926060a2cb28d0e729b Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Fri, 24 May 2024 18:26:41 +0900 Subject: [PATCH 2/2] chore: denoify --- deno_dist/request.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deno_dist/request.ts b/deno_dist/request.ts index 6fd80d42b..083f16be6 100644 --- a/deno_dist/request.ts +++ b/deno_dist/request.ts @@ -11,7 +11,7 @@ import type { } from './types.ts' import { parseBody } from './utils/body.ts' import type { BodyData, ParseBodyOptions } from './utils/body.ts' -import type { UnionToIntersection } from './utils/types.ts' +import type { Simplify, UnionToIntersection } from './utils/types.ts' import { getQueryParam, getQueryParams, decodeURIComponent_ } from './utils/url.ts' type Body = { @@ -80,7 +80,7 @@ export class HonoRequest

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