【发布时间】:2021-08-28 23:59:39
【问题描述】:
我大部分时间都花在这个问题上,但没有答案
错误:
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'User_Economy'. No index signature with a parameter of type 'string' was found on type 'User_Economy'.
interface User_Economy {
rep: number
money: number
level: number
xp: number
box: number[]
}
interface User_Interface{
Economy: User_Economy
}
data = await this.client.db.insert_one<User_Interface>('users', User_basic(member.id, message.guild.id));
const type: keyof {[key: string]: User_Economy} = ['level', 'money', 'rep', 'xp'].find(x => {
return typed.toLowerCase() === x ? x : null
})
data.Economy[type] += Math.floor(parseInt(amount));
如何解决这个问题?
【问题讨论】:
标签: javascript node.js typescript object types