fix: 修复 request ts 类型提示问题

This commit is contained in:
winixt 2022-11-15 15:30:13 +08:00
parent a3847f167a
commit 246900923a

View File

@ -7,14 +7,16 @@ type ResponseInterceptor = (value: AxiosResponse) => AxiosResponse | [(value: Ax
interface RequestPluginOption { interface RequestPluginOption {
mergeRequest?: boolean; mergeRequest?: boolean;
dataHandler?(data: any, response: AxiosResponse): any;
errorHandler?(error: AxiosError | {type: string, msg: string, [key: string]: string}): void;
cache?: boolean | { cache?: boolean | {
type: 'ram' | 'sessionStorage' | 'localStorage', type: 'ram' | 'sessionStorage' | 'localStorage',
cacheTime: number; cacheTime: number;
} }
} }
export function request(url: string, data: null | Record<string, any>, options: AxiosRequestConfig & RequestPluginOption ): Promise<any> export function request(url: string, data?: null | Record<string, any>, options?: AxiosRequestConfig & RequestPluginOption ): Promise<any>
export function useRequest(url: string, data: null | Record<string, any>, options: AxiosRequestConfig & RequestPluginOption ): {loadingRef: Ref<boolean>; errorRef: Ref<Error>; dataRef: Ref<any>} export function useRequest(url: string, data?: null | Record<string, any>, options?: AxiosRequestConfig & RequestPluginOption ): {loadingRef: Ref<boolean>; errorRef: Ref<Error>; dataRef: Ref<any>}
declare module "@fesjs/fes" { declare module "@fesjs/fes" {
interface PluginRuntimeConfig { interface PluginRuntimeConfig {
request?: { request?: {