Skip to content

Commit f73474d

Browse files
feat(types): Intellisense for string literals in a widened union (#6134)
- see: microsoft/TypeScript#33471 (comment) Co-authored-by: Jay <[email protected]>
1 parent d5b76d4 commit f73474d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

index.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// TypeScript Version: 4.7
2+
type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
3+
24
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
35

46
interface RawAxiosHeaders {
@@ -302,7 +304,7 @@ export interface AxiosProgressEvent {
302304

303305
type Milliseconds = number;
304306

305-
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
307+
type AxiosAdapterName = StringLiteralsOrString<'xhr' | 'http' | 'fetch'>;
306308

307309
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
308310

@@ -317,7 +319,7 @@ export type LookupAddress = string | LookupAddressEntry;
317319

318320
export interface AxiosRequestConfig<D = any> {
319321
url?: string;
320-
method?: Method | string;
322+
method?: StringLiteralsOrString<Method>;
321323
baseURL?: string;
322324
allowAbsoluteUrls?: boolean;
323325
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
@@ -332,7 +334,7 @@ export interface AxiosRequestConfig<D = any> {
332334
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
333335
auth?: AxiosBasicCredentials;
334336
responseType?: ResponseType;
335-
responseEncoding?: responseEncoding | string;
337+
responseEncoding?: StringLiteralsOrString<responseEncoding>;
336338
xsrfCookieName?: string;
337339
xsrfHeaderName?: string;
338340
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;

0 commit comments

Comments
 (0)