From 33750b8d5007a11d2495fd9b9690f3a407956752 Mon Sep 17 00:00:00 2001 From: Andreas Storesund Madsen Date: Fri, 14 Jun 2024 21:27:35 +0200 Subject: [PATCH] fix(types): use correct return type for c.html depending on input --- src/context.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/context.ts b/src/context.ts index b7755cc4f2..b1e8260369 100644 --- a/src/context.ts +++ b/src/context.ts @@ -175,10 +175,14 @@ type JSONRespondReturn< * @returns A Response object or a Promise that resolves to a Response object. */ interface HTMLRespond { - (html: string | Promise, status?: StatusCode, headers?: HeaderRecord): - | Response - | Promise - (html: string | Promise, init?: ResponseInit): Response | Promise + >( + html: T, + status?: StatusCode, + headers?: HeaderRecord + ): T extends string ? Response : Promise + >(html: T, init?: ResponseInit): T extends string + ? Response + : Promise } /**