[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。

- 发布:2024-09-29 08:47
- 更新:2024-10-04 16:53
- 阅读:640
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win11
HBuilderX类型: 正式
HBuilderX版本号: 4.28
手机系统: Android
手机系统版本号: Android 12
手机厂商: vivo
手机机型: iqoo
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
操作步骤:
预期结果:
编译正常
编译正常
实际结果:
编译提示报错
编译提示报错
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版本的
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