重回第一天之dlc

在新建picture.ts后,定义了常量文件,中文映射,筛选审核状态后,我的编译器报了错误,但是鱼总没有,让ai检查了一下:

text
复制代码
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ 0: string; 1: string; 2: string; }'.<br/>No index signature with a parameter of type 'string' was found on type '{ 0: string; 1: string; 2: string; }'

发现是一个索引类型的小问题,

text
复制代码
export const PIC_REVIEW_STATUS_OPTIONS = Object.keys(PIC_REVIEW_STATUS_MAP).map((key) => { return { label: PIC_REVIEW_STATUS_MAP[key], value: key, } }

修改为

text
复制代码
export const PIC_REVIEW_STATUS_OPTIONS = Object.entries(PIC_REVIEW_STATUS_MAP).map(([key, value]) => ({ label: value, value: Number(key), }), )

就不报错了

0个评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
下载 APP