From 2d2314a1ac29ce6723eb53e130b4a36617fd201c Mon Sep 17 00:00:00 2001 From: Dmitriy Mozgovoy Date: Thu, 28 May 2026 19:55:27 +0300 Subject: [PATCH] fix: AxiosHeaders `toJSON()` return types (#10956) * fix(types): fix AxiosHeaders `toJSON` types; * Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * fix(types): add a boolean catch-all overload; --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- README.md | 3 ++- index.d.cts | 4 +++- index.d.ts | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ed78af25..9d1a9a3b 100644 --- a/README.md +++ b/README.md @@ -2161,7 +2161,8 @@ Returns a new `AxiosHeaders` instance. ### AxiosHeaders#toJSON(asStrings?) ``` -toJSON(asStrings?: boolean): RawAxiosHeaders; +toJSON(asStrings: true): Record; +toJSON(asStrings?: false): Record; ``` Resolve all internal header values into a new null prototype object. diff --git a/index.d.cts b/index.d.cts index 30b093ef..2e17a8e4 100644 --- a/index.d.cts +++ b/index.d.cts @@ -66,7 +66,9 @@ declare class AxiosHeaders { ...targets: Array ): AxiosHeaders; - toJSON(asStrings?: boolean): axios.RawAxiosHeaders; + toJSON(asStrings: true): Record; + toJSON(asStrings?: false): Record; + toJSON(asStrings?: boolean): Record; static from(thing?: AxiosHeaders | axios.RawAxiosHeaders | string): AxiosHeaders; diff --git a/index.d.ts b/index.d.ts index a43f3865..7304f5fa 100644 --- a/index.d.ts +++ b/index.d.ts @@ -47,7 +47,9 @@ export class AxiosHeaders { ...targets: Array ): AxiosHeaders; - toJSON(asStrings?: boolean): RawAxiosHeaders; + toJSON(asStrings: true): Record; + toJSON(asStrings?: false): Record; + toJSON(asStrings?: boolean): Record; static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;