Skip to content

Commit

Permalink
feat(RequestTemplate): request添加类型重载,json与非json分开
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxinssfd committed Jan 11, 2023
1 parent 46905f6 commit 952ad90
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/request-template/src/RequestTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,29 @@ export abstract class RequestTemplate<CC extends CustomConfig = CustomConfig> {

/**
* 模板方法,请求入口,重试不会执行该方法
* ---
* json类返回值类型
* @overload
*/
request<T = never, RC extends boolean = false>(
requestConfig: Omit<AxiosRequestConfig, 'cancelToken' | 'url'> & { url: string },
requestConfig: Omit<AxiosRequestConfig, 'cancelToken' | 'url' | 'responseType'> & {
url: string;
responseType?: 'json';
},
customConfig?: DynamicCustomConfig<CC, RC>,
): Promise<RC extends true ? AxiosResponse<ResType<T>> : ResType<T>>;
/**
* 模板方法,请求入口,重试不会执行该方法
* ---
* 非json返回值类型
* @overload
*/
request<T = never, RC extends boolean = false>(
requestConfig: Omit<AxiosRequestConfig, 'cancelToken' | 'url'> & {
url: string;
},
customConfig?: DynamicCustomConfig<CC, RC>,
): Promise<RC extends true ? AxiosResponse<T> : T>;
/**
* 模板方法,请求入口,重试不会执行该方法
*/
Expand Down

0 comments on commit 952ad90

Please sign in to comment.