From 5d537c55c0c3d409afa04c600954aefa77a6c57b Mon Sep 17 00:00:00 2001
From: winixt <haizekuo@gmail.com>
Date: Tue, 21 Feb 2023 20:05:25 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20.d.ts=20=E7=B1=BB=E5=9E=8B=E5=BC=82?=
 =?UTF-8?q?=E5=B8=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 packages/fes-plugin-access/types.d.ts   |  2 +-
 packages/fes-plugin-layout/types.d.ts   | 39 +++++++-------
 packages/fes-plugin-request/types.d.ts  | 32 ++++++-----
 packages/fes-preset-built-in/types.d.ts | 70 ++++++++++++-------------
 4 files changed, 75 insertions(+), 68 deletions(-)

diff --git a/packages/fes-plugin-access/types.d.ts b/packages/fes-plugin-access/types.d.ts
index a692f670..78c342fb 100644
--- a/packages/fes-plugin-access/types.d.ts
+++ b/packages/fes-plugin-access/types.d.ts
@@ -1,7 +1,7 @@
 import { Router, NavigationGuard } from 'vue-router';
 import { Ref } from 'vue';
 
-export function access(): {
+export const access: {
     hasAccess(accessId: string | number): Promise<boolean>;
     isDataReady(): boolean;
     setRole(roleId: string | Promise<string>): void;
diff --git a/packages/fes-plugin-layout/types.d.ts b/packages/fes-plugin-layout/types.d.ts
index ad845495..c88eefa2 100644
--- a/packages/fes-plugin-layout/types.d.ts
+++ b/packages/fes-plugin-layout/types.d.ts
@@ -15,8 +15,8 @@ declare module '@fesjs/fes' {
     interface RouteMeta {
         'keep-alive'?: boolean;
         layout?: {
-            navigation?: 'side' | 'mixin' | 'top' | 'left-right' | null,
-        }
+            navigation?: 'side' | 'mixin' | 'top' | 'left-right' | null;
+        };
     }
     interface PluginBuildConfig {
         layout?:
@@ -41,25 +41,24 @@ declare module '@fesjs/fes' {
     }
     interface PluginRuntimeConfig {
         layout?: {
-            footer: string;
-            theme: 'dark' | 'light';
-            navigation: 'side' | 'top' | 'mixin' | 'left-right';
-            title: string;
-            isFixedHeader: boolean;
-            isFixedSidebar: boolean;
-            logo: string;
-            multiTabs: boolean;
-            sideWidth: number;
-            menus: Menu[] | (() => Ref<Menu[]> | Menu[]);
-            menuProps: {
-                expandedKeys: string[];
-                defaultExpandAll: boolean;
-                accordion: boolean;
+            footer?: string;
+            theme?: 'dark' | 'light';
+            navigation?: 'side' | 'top' | 'mixin' | 'left-right';
+            title?: string;
+            isFixedHeader?: boolean;
+            isFixedSidebar?: boolean;
+            logo?: string;
+            multiTabs?: boolean;
+            sideWidth?: number;
+            menus?: Menu[] | (() => Ref<Menu[]> | Menu[]);
+            menuProps?: {
+                expandedKeys?: string[];
+                defaultExpandAll?: boolean;
+                accordion?: boolean;
             };
-            renderCustom: () => VNode[];
-            noFoundHandler: (param: { router: Router } & NavigationGuard) => void;
-            unAccessHandler: (param: { router: Router } & NavigationGuard) => void;
+            renderCustom?: () => VNode | VNode[];
+            noFoundHandler?: (param: { router: Router } & NavigationGuard) => void;
+            unAccessHandler?: (param: { router: Router } & NavigationGuard) => void;
         };
     }
-
 }
diff --git a/packages/fes-plugin-request/types.d.ts b/packages/fes-plugin-request/types.d.ts
index 5332f339..225c92cf 100644
--- a/packages/fes-plugin-request/types.d.ts
+++ b/packages/fes-plugin-request/types.d.ts
@@ -1,31 +1,39 @@
 import { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
-import {Ref} from 'vue';
-
+import { Ref } from 'vue';
 
 type RequestInterceptor = (value: AxiosRequestConfig) => AxiosRequestConfig | [(value: AxiosRequestConfig) => AxiosRequestConfig, (error: any) => any];
 type ResponseInterceptor = (value: AxiosResponse) => AxiosResponse | [(value: AxiosResponse) => AxiosResponse, (error: any) => any];
 
+export type RequestResponse = AxiosResponse;
+export type RequestError = AxiosError & { type: string; msg: string; [key: string]: any };
 interface RequestPluginOption {
     mergeRequest?: boolean;
     dataHandler?(data: any, response: AxiosResponse): any;
-    errorHandler?(error: AxiosError | {type: string, msg: string, [key: string]: string}): void;
-    cache?: boolean | {
-        type: 'ram' | 'sessionStorage' | 'localStorage',
-        cacheTime: number;
-    }
+    errorHandler?(error: RequestError): void;
+    cache?:
+        | boolean
+        | {
+              type?: 'ram' | 'sessionStorage' | 'localStorage';
+              cacheTime?: number;
+          };
 }
 
 export type RequestOptions = AxiosRequestConfig & RequestPluginOption;
 
-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>}
-declare module "@fesjs/fes" {
+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> };
+
+declare module '@fesjs/fes' {
     interface PluginRuntimeConfig {
         request?: {
             dataHandler?(data: any, response: AxiosResponse): any;
-            errorHandler?(error: AxiosError | {type: string, msg: string, [key: string]: string}): void;
+            errorHandler?(error: RequestError): void;
             requestInterceptors?: RequestInterceptor[];
             responseInterceptors?: ResponseInterceptor[];
         } & AxiosRequestConfig;
     }
-}
\ No newline at end of file
+}
diff --git a/packages/fes-preset-built-in/types.d.ts b/packages/fes-preset-built-in/types.d.ts
index c7c32a12..4b4b449c 100644
--- a/packages/fes-preset-built-in/types.d.ts
+++ b/packages/fes-preset-built-in/types.d.ts
@@ -1,4 +1,4 @@
-import { Component, DefineComponent, App } from 'vue';
+import { Component, DefineComponent, Component, App } from 'vue';
 import { RouteRecordRaw, Router, RouterHistory, createMemoryHistory, createWebHashHistory, createWebHistory } from 'vue-router';
 
 // @ts-ignore
@@ -16,77 +16,78 @@ interface ClientRenderOption {
     plugin: Plugin;
 }
 
-type RenderFunc = () => Promise<App>
+type RenderFunc = () => Promise<App>;
 
-interface Route  {
-    base: string; 
-    mode:string;  
+interface Route {
+    base: string;
+    mode: string;
     createHistory: createMemoryHistory | createWebHashHistory | createWebHistory;
 }
 
-
 export function getRouter(): Router;
 export function getHistory(): RouterHistory;
 export function destroyRouter(): void;
 
 declare module '@fesjs/fes' {
     interface PluginRuntimeConfig {
-        beforeRender?: (option: BeforeRenderConfig) => BeforeRenderConfig;
+        beforeRender?: BeforeRenderConfig;
         patchRoutes?: ({ routes }: { routes: RouteRecordRaw[] }) => void;
-        modifyRoute?: ({base, mode, createHistory }: Route) => Route;
+        modifyRoute?: ({ base, mode, createHistory }: Route) => Route;
         modifyClientRenderOpts?: (option: ClientRenderOption) => ClientRenderOption;
-        rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[], plugin: Plugin }) => Component;
-        onAppCreated?: ({ app, routes }: { app: App, routes: RouteRecordRaw[] }) => void;
+        rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[]; plugin: Plugin }) => Component;
+        onAppCreated?: ({ app, routes }: { app: App; routes: RouteRecordRaw[] }) => void;
         render?: (defaultRender: RenderFunc) => RenderFunc;
         onRouterCreated?: ({ router }: { router: Router }) => void;
     }
 
     interface PluginBuildConfig {
-        alias?: Record<string, string>,
+        alias?: Record<string, string>;
         autoprefixer?: {
             /** environment for `Browserslist` */
-            env?: string
-        
+            env?: string;
+
             /** should Autoprefixer use Visual Cascade, if CSS is uncompressed */
-            cascade?: boolean
-        
+            cascade?: boolean;
+
             /** should Autoprefixer add prefixes. */
-            add?: boolean
-        
+            add?: boolean;
+
             /** should Autoprefixer [remove outdated] prefixes */
-            remove?: boolean
-        
+            remove?: boolean;
+
             /** should Autoprefixer add prefixes for @supports parameters. */
-            supports?: boolean
-        
+            supports?: boolean;
+
             /** should Autoprefixer add prefixes for flexbox properties */
-            flexbox?: boolean | 'no-2009'
-        
+            flexbox?: boolean | 'no-2009';
+
             /** should Autoprefixer add IE 10-11 prefixes for Grid Layout properties */
-            grid?: boolean
-        
+            grid?: boolean;
+
             /**
              * list of queries for target browsers.
              * Try to not use it.
              * The best practice is to use `.browserslistrc` config or `browserslist` key in `package.json`
              * to share target browsers with Babel, ESLint and Stylelint
              */
-            overrideBrowserslist?: string | string[]
-        
+            overrideBrowserslist?: string | string[];
+
             /** do not raise error on unknown browser version in `Browserslist` config. */
-            ignoreUnknownVersions?: boolean
+            ignoreUnknownVersions?: boolean;
         };
-        define?: Record<string, string | object>,
+        define?: Record<string, string | object>;
         router?: {
             base?: string;
             routes?: RouteRecordRaw[];
-            mode?: 'hash' | 'history' | 'memory'
+            mode?: 'hash' | 'history' | 'memory';
         };
         dynamicImport?: boolean;
         inlineLimit?: number;
-        mock?: boolean | {
-            prefix?: string;
-        };
+        mock?:
+            | boolean
+            | {
+                  prefix?: string;
+              };
         mountElementId?: string;
         plugins?: string[];
         presets?: string[];
@@ -94,7 +95,7 @@ declare module '@fesjs/fes' {
             [apiPrefix: string]: {
                 target: string;
                 changeOrigin?: boolean;
-            }
+            };
         };
         publicPath?: string;
         singular?: boolean;
@@ -102,5 +103,4 @@ declare module '@fesjs/fes' {
         terserOptions?: object;
         title?: string;
     }
-    
 }