From f73474d02c5aa957b2daeecee65508557fd3c6e5 Mon Sep 17 00:00:00 2001 From: svihpinc <115612815+svihpinc@users.noreply.github.com> Date: Thu, 13 Nov 2025 00:47:57 +0530 Subject: [PATCH] feat(types): Intellisense for string literals in a widened union (#6134) - see: https://github.com/microsoft/TypeScript/issues/33471#issuecomment-1376364329 Co-authored-by: Jay --- index.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index dc3e809..ff29215 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,6 @@ // TypeScript Version: 4.7 +type StringLiteralsOrString = Literals | (string & {}); + export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null; interface RawAxiosHeaders { @@ -302,7 +304,7 @@ export interface AxiosProgressEvent { type Milliseconds = number; -type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {}); +type AxiosAdapterName = StringLiteralsOrString<'xhr' | 'http' | 'fetch'>; type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName; @@ -317,7 +319,7 @@ export type LookupAddress = string | LookupAddressEntry; export interface AxiosRequestConfig { url?: string; - method?: Method | string; + method?: StringLiteralsOrString; baseURL?: string; allowAbsoluteUrls?: boolean; transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[]; @@ -332,7 +334,7 @@ export interface AxiosRequestConfig { adapter?: AxiosAdapterConfig | AxiosAdapterConfig[]; auth?: AxiosBasicCredentials; responseType?: ResponseType; - responseEncoding?: responseEncoding | string; + responseEncoding?: StringLiteralsOrString; xsrfCookieName?: string; xsrfHeaderName?: string; onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;