mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
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 <jasonsaayman@gmail.com>
This commit is contained in:
Vendored
+5
-3
@@ -1,4 +1,6 @@
|
|||||||
// TypeScript Version: 4.7
|
// TypeScript Version: 4.7
|
||||||
|
type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
|
||||||
|
|
||||||
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
||||||
|
|
||||||
interface RawAxiosHeaders {
|
interface RawAxiosHeaders {
|
||||||
@@ -302,7 +304,7 @@ export interface AxiosProgressEvent {
|
|||||||
|
|
||||||
type Milliseconds = number;
|
type Milliseconds = number;
|
||||||
|
|
||||||
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
|
type AxiosAdapterName = StringLiteralsOrString<'xhr' | 'http' | 'fetch'>;
|
||||||
|
|
||||||
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
||||||
|
|
||||||
@@ -317,7 +319,7 @@ export type LookupAddress = string | LookupAddressEntry;
|
|||||||
|
|
||||||
export interface AxiosRequestConfig<D = any> {
|
export interface AxiosRequestConfig<D = any> {
|
||||||
url?: string;
|
url?: string;
|
||||||
method?: Method | string;
|
method?: StringLiteralsOrString<Method>;
|
||||||
baseURL?: string;
|
baseURL?: string;
|
||||||
allowAbsoluteUrls?: boolean;
|
allowAbsoluteUrls?: boolean;
|
||||||
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
||||||
@@ -332,7 +334,7 @@ export interface AxiosRequestConfig<D = any> {
|
|||||||
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
||||||
auth?: AxiosBasicCredentials;
|
auth?: AxiosBasicCredentials;
|
||||||
responseType?: ResponseType;
|
responseType?: ResponseType;
|
||||||
responseEncoding?: responseEncoding | string;
|
responseEncoding?: StringLiteralsOrString<responseEncoding>;
|
||||||
xsrfCookieName?: string;
|
xsrfCookieName?: string;
|
||||||
xsrfHeaderName?: string;
|
xsrfHeaderName?: string;
|
||||||
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
||||||
|
|||||||
Reference in New Issue
Block a user