【发布时间】:2019-11-19 21:51:30
【问题描述】:
已编辑:更改 ID 类型
我有一个包含以下值的数组
const ids: number[] = [45, 56];
const obj: any = {
45: "HELLO",
56: "WORLD",
};
我想输入我的对象的当前any 类型,以将其限制为我的ids 数组值。
我尝试了查找类型,但没有成功……
有什么想法吗?
问候
【问题讨论】:
-
顺便说一句,
const ids: string[] = [45, 56];行是错误的;45和56不是strings。
标签: typescript types typescript-typings