Selaa lähdekoodia

refactor(types): 使用AxiosRequestConfig简化全局类型声明

yz 1 viikko sitten
vanhempi
commit
82817439eb
2 muutettua tiedostoa jossa 76 lisäystä ja 6 poistoa
  1. 3 6
      src/types/global.d.ts
  2. 73 0
      tsconfig.json

+ 3 - 6
src/types/global.d.ts

@@ -1,4 +1,6 @@
 // types/global.d.ts
+import {AxiosRequestConfig} from "axios";
+
 declare global {
     interface AxiosResponse<T = any> {
         data: ApiResponseData<T>;
@@ -8,12 +10,7 @@ declare global {
             [key: string]: string;
             'content-type'?: string;
         };
-        config: {
-            method?: string;
-            url?: string;
-            params?: Record<string, any>;
-            headers?: Record<string, any>;
-        };
+        config: AxiosRequestConfig;
     }
 
     interface ApiResponse<T = any> {

+ 73 - 0
tsconfig.json

@@ -0,0 +1,73 @@
+{
+  "compilerOptions": {
+    "target": "es5",
+    "lib": [
+      "dom",
+      "dom.iterable",
+      "es6"
+    ],
+    "allowJs": true,
+    "skipLibCheck": true,
+    "esModuleInterop": true,
+    "allowSyntheticDefaultImports": true,
+    "strict": false,
+    "forceConsistentCasingInFileNames": true,
+    "module": "esnext",
+    "moduleResolution": "node",
+    "resolveJsonModule": true,
+    "isolatedModules": true,
+    "noEmit": true,
+    "jsx": "preserve",
+    "declaration": false,
+    "declarationMap": false,
+    "sourceMap": true,
+    "baseUrl": ".",
+    "paths": {
+      "@/*": ["src/*"],
+      "@/api/*": ["src/api/*"],
+      "@/assets/*": ["src/assets/*"],
+      "@/components/*": ["src/components/*"],
+      "@/config/*": ["src/config/*"],
+      "@/constants/*": ["src/constants/*"],
+      "@/lang/*": ["src/lang/*"],
+      "@/mixins/*": ["src/mixins/*"],
+      "@/router/*": ["src/router/*"],
+      "@/store/*": ["src/store/*"],
+      "@/styles/*": ["src/styles/*"],
+      "@/types/*": ["src/types/*"],
+      "@/util/*": ["src/util/*"],
+      "@/views/*": ["src/views/*"]
+    },
+    "types": [
+      "node",
+      "webpack-env"
+    ],
+    "typeRoots": [
+      "node_modules/@types",
+      "src/types"
+    ],
+    "experimentalDecorators": true,
+    "emitDecoratorMetadata": true,
+    "noImplicitAny": false,
+    "noImplicitReturns": false,
+    "noImplicitThis": false,
+    "strictNullChecks": false,
+    "suppressImplicitAnyIndexErrors": true
+  },
+  "include": [
+    "src/**/*.ts",
+    "src/**/*.tsx",
+    "src/**/*.vue",
+    "src/**/*.js",
+    "src/**/*.jsx",
+    "src/types/**/*.d.ts"
+  ],
+  "exclude": [
+    "node_modules",
+    "dist",
+    "public",
+    "**/*.spec.ts",
+    "**/*.test.ts"
+  ],
+  "compileOnSave": false
+}