Skip to content

Commit

Permalink
add: Intellisense for string literals in a widened union
Browse files Browse the repository at this point in the history
  • Loading branch information
svihpinc authored Dec 14, 2023
1 parent b3be365 commit 8d1be41
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// TypeScript Version: 4.7
type StringLiteralsOrString<Literals extends string> = Literals | (string & {});

export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;

interface RawAxiosHeaders {
Expand Down Expand Up @@ -298,7 +300,7 @@ export interface AxiosProgressEvent {

type Milliseconds = number;

type AxiosAdapterName = 'xhr' | 'http' | string;
type AxiosAdapterName = StringLiteralsOrString<'xhr' | 'http'>;

type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;

Expand All @@ -313,7 +315,7 @@ export type LookupAddress = string | LookupAddressEntry;

export interface AxiosRequestConfig<D = any> {
url?: string;
method?: Method | string;
method?: StringLiteralsOrString<Method>;
baseURL?: string;
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
Expand All @@ -327,7 +329,7 @@ export interface AxiosRequestConfig<D = any> {
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
auth?: AxiosBasicCredentials;
responseType?: ResponseType;
responseEncoding?: responseEncoding | string;
responseEncoding?: StringLiteralsOrString<responseEncoding>;
xsrfCookieName?: string;
xsrfHeaderName?: string;
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
Expand Down

0 comments on commit 8d1be41

Please sign in to comment.