HarmonyOS_Next 星河版迁移报错记录【自用】

Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)
对象字面量必须对应于一些显式声明的类或接口(arkts-no-untyped-obj-literals)

// ❌
const opt = {
  size: { height: 3, width: 5 },
  pixelFormat: 3,
  editable: true,
  alphaType: 1,
  scaleMode: 1
};

Use explicit types instead of "any", "unknown" (arkts-no-any-unknown)
使用显式类型代替"any", "unknown" (arkts-no-any-unknown)

Property 'title' has no initializer and is not definitely assigned in the constructor.
属性'title'没有初始化器,也没有在构造函数中明确赋值。< ArkTSCheck >

@Component
export struct TitleDividerComp {
  title: string  // ❌
  title: string = '' // ✅
  fontSize?: number = 14

  build() {
    Row() {
      Text(this.title)
        .fontSize(this.fontSize)
        .fontWeight(500)
        .fontColor($r('app.color.font_sub'))
    }
    .width('100%')
    .height(40)
    .backgroundColor($r('app.color.background'))
    .padding({ left: 20, right: 20 })
  }
}

You are advised to initialize the width and height attributes of the List component.
建议初始化List组件的width和height属性。< ArkTSCheck >

Declaration merging is not supported (arkts-no-decl-merging)
不支持声明合并(arkts-no- declare - merge)

interface Item {
  id: string
  name: string
  tel: string
}

Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)
泛型函数调用的类型推断是有限的(arkts-no- infer- generic-params)

  list: string[] = Array.from({ length: 5 }, () => Math.random()
    .toString()
    .slice(2, 2+4))
list: string[] = Array(5).fill(Math.random().toString().slice(2, 2 + 4))
posted @   MegaSu  阅读(8312)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~
点击右上角即可分享
微信分享提示