关于Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck> 报错
// Define the message sync trigger types
type MsgSyncTriggerTypeUnique = "poll" | "longlink" | "wakeup" | "newlongink" | "pushwakeup";
// Export the message sync trigger types
export const MsgSyncTriggerType = {
POLL: "poll" as MsgSyncTriggerTypeUnique,
LONG_LINK: "longlink" as MsgSyncTriggerTypeUnique,
WAKE_UP: "wakeup" as MsgSyncTriggerTypeUnique,
NEW_LONG_LINK: "newlongink" as MsgSyncTriggerTypeUnique,
WAKE_UP_PUSH: "pushwakeup" as MsgSyncTriggerTypeUnique,
};
这样定义类型报错:Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck>
本文参与了思否 HarmonyOS 技术问答马拉松,欢迎正在阅读的你也加入。
ArkTS在TS基础商机进行了约束,不支持对象类型中包含call signature。
这种情况可以定义为一种枚举: