v0.5.1 为 PATCH 版本,修复打包安卓基座时触发的 UTS 编译错误(
UTS110111101: direct declaration of Object Literal Type is not supported)。本版本仅 core 变化,无 API 变更、无破坏性变更。
一、问题现象
打包安卓基座(云打包 / 本地打包)时提示:
error UTS110111101: direct declaration of Object Literal Type is not supported
at uni_modules\ux-router\utssdk\history\uni-history.uts:20:18
出错位置为 UniHistory.currentStack() 的返回类型:
currentStack(): { path: string; query: Map<string, string> } {
// ...
}
二、根因
UTS 不允许在函数签名中直接声明内联对象字面量类型(Kotlin / Swift 等原生端无此语法)。该写法在 Web / 小程序(编译为 JS)端可运行,但在 Android(编译为 Kotlin)端编译期即报 UTS110111101。
三、修复
提取为具名类型 CurrentStackInfo 并在返回类型中引用:
/** 页面栈顶信息(具名类型,规避 UTS 不允许内联对象字面量类型作为注解) */
export interface CurrentStackInfo {
path: string
query: Map<string, string>
}
export class UniHistory {
// ...
currentStack(): CurrentStackInfo {
// 原实现不变
}
}
四、版本说明
本次为 PATCH(0.5.0 → 0.5.1):仅修复编译错误,无新功能、无 API / 破坏性变更,升级无需任何改动。
版本兼容性
| 功能 | 0.5.0 | 0.5.1 |
|---|---|---|
| 核心 API | ✅ | ✅(不变) |
currentStack() 签名 | 内联对象字面量(Android 编译失败) | ✅ 具名类型 CurrentStackInfo |
| 打包安卓基座 | ❌ 编译失败 | ✅ |
五、相关链接
欢迎反馈与共建:GitHub