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 @ 2024-01-26 18:08  MegaSu  阅读(5348)  评论(0编辑  收藏  举报