From 04aa38348ffad6676380153a5ed0c36b317ac9e5 Mon Sep 17 00:00:00 2001 From: Dan Hensby Date: Tue, 16 Jun 2026 12:09:30 +0100 Subject: [PATCH] fix(types): accept framework request types in the Request constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 5.2.1 the Request constructor typed `headers` and `query` as `Record`, which rejects common framework request shapes at compile time — e.g. Express 5's `req.query` (`ParsedQs`, whose values can be nested or `undefined`) and Koa's `IncomingHttpHeaders` (`string | string[] | undefined`). Widen both to `Record`, which accepts those shapes while remaining backwards compatible with plain `Record` callers. `headers`/`method`/`query` stay required, so a raw Fetch `Request` (which has no `query`) still correctly fails to type-check. Co-Authored-By: Claude Opus 4.8 (1M context) --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index e67540b..1ef7c62 100644 --- a/index.d.ts +++ b/index.d.ts @@ -53,18 +53,18 @@ declare namespace OAuth2Server { */ class Request { body?: any; - headers?: Record; + headers?: Record; method?: string; - query?: Record; + query?: Record; /** * Instantiates Request using the supplied options. * */ constructor(options: { - headers: Record, + headers: Record, method: string, - query: Record, + query: Record, body?: any } & Record | http.IncomingMessage);