类型为“{ params:对象; }'不能赋值给类型“AxiosRequestConfig”的参数< any>

ggazkfy8  于 2023-04-30  发布在  iOS
关注(0)|答案(1)|浏览(465)

运行yarn install后出现此错误

(typescript) Error: /builds/frontend/utils/src/hooks/useReactQuery.ts(29,21): semantic error TS2345: Argument of type '{ params: object; }' is not assignable to parameter of type 'AxiosRequestConfig<any>'.
  Property 'string' is missing in type '{ params: object; }' but required in type 'AxiosRequestConfig<any>'.
Error: /builds/frontend/utils/src/hooks/useReactQuery.ts(29,21): semantic error TS2345: Argument of type '{ params: object; }' is not assignable to parameter of type 'AxiosRequestConfig<any>'.
  Property 'string' is missing in type '{ params: object; }' but required in type 'AxiosRequestConfig<any>'.
    at error (/builds/frontend/utils/node_modules/rollup/dist/shared/node-entry.js:5400:30)
    at throwPluginError (/builds/frontend/utils/node_modules/rollup/dist/shared/node-entry.js:11878:12)
    at Object.error (/builds/frontend/utils/node_modules/rollup/dist/shared/node-entry.js:12912:24)
    at Object.error (/builds/frontend/utils/node_modules/rollup/dist/shared/node-entry.js:12081:38)
    at RollupContext.error (/builds/frontend/utils/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:17237:30)
    at /builds/frontend/utils/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25033:23
    at arrayEach (/builds/frontend/utils/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:545:11)
    at Function.forEach (/builds/frontend/utils/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:9397:14)
    at printDiagnostics (/builds/frontend/utils/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25006:12)
    at Object.transform (/builds/frontend/utils/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29277:17)
    at /builds/frontend/utils/node_modules/rollup/dist/shared/node-entry.js:13117:25
    at runNextTicks (internal/process/task_queues.js:60:5)
    at processImmediate (internal/timers.js:437:9)
error Command failed with exit code 1.

节点版本:14.19.1
我该如何解决这个问题?

9gm1akwq

9gm1akwq1#

我找到了!它与新版本的axios 1.4.0有关。我将Axios的版本降级到1.3.0

"dependencies": {
    "axios": "1.3.0"
}

成功了!

相关问题