From 84af6e6ebf69e10adcd44601d8638b29aad8568f Mon Sep 17 00:00:00 2001 From: jkalberer <90280207+jkalberer@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:30:13 -0700 Subject: [PATCH] Fix build error from RawAxiosHeaders I'm getting the following error: ``` Exported variable 'runRules' has or is using name 'RawAxiosHeaders' from external module ".../axios/index" but cannot be named. ``` For code that looks like this: ``` export const runRules = (options: Options) => { return (options?.client ?? client).post({ ...options, url: '/fixer/run', }); }; ``` The build error is happening for APIs where the `body` is a required parameter. --- I think the main issue here is that `RawAxiosHeaders` is not exported from `axios` but you're using it as an exported type here. Anyways, `AxiosRequestHeaders` + your `Record` type seems to cover most of what `CreateAxiosDefaults['headers']` includes. --- packages/client-axios/src/types.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/client-axios/src/types.ts b/packages/client-axios/src/types.ts index e1f2719d9..e4658f9b0 100644 --- a/packages/client-axios/src/types.ts +++ b/packages/client-axios/src/types.ts @@ -5,6 +5,7 @@ import type { AxiosResponse, AxiosStatic, CreateAxiosDefaults, + AxiosRequestHeaders } from 'axios'; import type { BodySerializer } from './utils'; @@ -37,7 +38,7 @@ export interface Config * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} */ headers?: - | CreateAxiosDefaults['headers'] + | AxiosRequestHeaders | Record< string, | string