snakesking
snakesking
  • 发布:2024-09-29 08:47
  • 更新:2024-10-04 16:53
  • 阅读:640

【报Bug】HBuilder X4.28版本编译4.24版本的uniappx项目,提示类型错误的问题,但是项目本身是没有问题的

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win11

HBuilderX类型: 正式

HBuilderX版本号: 4.28

手机系统: Android

手机系统版本号: Android 12

手机厂商: vivo

手机机型: iqoo

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

[plugin:uni:app-uts] 编译失败
08:42:21.500 ‌error: 类型不匹配: 推断类型是Any,但预期的是IUTSObject。‌
08:42:21.500 at utils/interceptors.uts:20:31
08:42:21.500 18 | .useRequest((options) : RequestConfig => {
08:42:21.500 19 | console.log('请求拦截', options);
08:42:21.500 20 | options.data = Object.assign(options.data ?? {}, {
08:42:21.500 | ^
08:42:21.500 21 | a: 1
08:42:21.500 22 | })
08:42:21.500 ‌error: 类型不匹配: 推断类型是uts.sdk.modules.kuxRequest.RequestConfig,但预期的是uni.UNI6C2103C.RequestConfig。‌
08:42:21.500 at requestApis/user/index.uts:8:40
08:42:21.500 6 | */
08:42:21.500 7 | export const getUserInfoApi = (loginFromType : string) : Promise<any> => {
08:42:21.500 8 | return http.get(uc/user/getUserInfo/${loginFromType}, {
08:42:21.500 | ^
08:42:21.500 9 | debug: true, header: {
08:42:21.500 10 | Authorization: "bearer " + JSON.parse(uni.getStorageSync('tokenStr') as string),
08:42:21.500 ‌error: 类型不匹配: 推断类型是uts.sdk.modules.kuxRequest.RequestConfig,但预期的是uni.UNI6C2103C.RequestConfig。‌

预期结果:

编译正常

实际结果:

编译提示报错

bug描述:

使用HBuilder X最新版本4.28,运行uniappx项目报错
[plugin:uni:app-uts] 编译失败
08:42:21.500 ‌error: 类型不匹配: 推断类型是Any,但预期的是IUTSObject。‌
08:42:21.500 at utils/interceptors.uts:20:31
08:42:21.500 18 | .useRequest((options) : RequestConfig => {
08:42:21.500 19 | console.log('请求拦截', options);
08:42:21.500 20 | options.data = Object.assign(options.data ?? {}, {
08:42:21.500 | ^
08:42:21.500 21 | a: 1
08:42:21.500 22 | })
08:42:21.500 ‌error: 类型不匹配: 推断类型是uts.sdk.modules.kuxRequest.RequestConfig,但预期的是uni.UNI6C2103C.RequestConfig。‌
08:42:21.500 at requestApis/user/index.uts:8:40
08:42:21.500 6 | /
08:42:21.500 7 | export const getUserInfoApi = (loginFromType : string) : Promise<any> => {
08:42:21.500 8 | return http.get(uc/user/getUserInfo/${loginFromType}, {
08:42:21.500 | ^
08:42:21.500 9 | debug: true, header: {
08:42:21.500 10 | Authorization: "bearer " + JSON.parse(uni.getStorageSync('tokenStr') as string),
08:42:21.500 ‌error: 类型不匹配: 推断类型是uts.sdk.modules.kuxRequest.RequestConfig,但预期的是uni.UNI6C2103C.RequestConfig。‌
08:42:21.500 at requestApis/user/index.uts:20:17
08:42:21.500 18 |
/
08:42:21.500 19 | export const getCurrentListApi = () : Promise<any> => {
08:42:21.500 20 | return http.get('uc/identity/getCurrentList', {
08:42:21.500 | ^
08:42:21.500 21 | debug: true, header: {
08:42:21.501 22 | Authorization: "bearer " + JSON.parse(uni.getStorageSync('tokenStr') as string),
08:42:21.501 ‌error: 类型不匹配: 推断类型是uts.sdk.modules.kuxRequest.RequestConfig,但预期的是uni.UNI6C2103C.RequestConfig。‌
但是HBuilder X4.24版本运行正常,我是直接从4.24版本升级到4.28版本的

2024-09-29 08:47 负责人:无 分享
已邀请:
DCloud_UNI_FengXY

DCloud_UNI_FengXY

可以升级你使用的三方request插件至最新版本

  • snakesking (作者)

    也就是说第三方插件需要更新最新版本的才能适配当前4.28版本吗?我现在插件就是使用的最新版本,那么这个插件的最新版本现在只能适配到4.24版本,我可以这么理解吧

    2024-09-29 15:23

  • DCloud_UNI_FengXY

    回复 snakesking: 你可以联系插件作者,看报错,应该是使用方式有问题。

    2024-09-29 15:34

  • DCloud_UNI_FengXY

    应该是你的代码里直接引入了他插件内部的文件,正确的用法,应该是 import { RequestConfig } from '@/uni_modules/kux-request'; 不要直接引入插件内部的文件。

    2024-09-29 15:36

  • snakesking (作者)

    回复 DCloud_UNI_FengXY: 好的,感谢解惑

    2024-09-30 08:53

2***@qq.com

2***@qq.com

最新发布出来的sdk下载后是28。而hbx升级后是29了已经。还是提示这个

要回复问题请先登录注册