我有 en.json 和 ru.json 文件,我在那里按类型使用变量:
levelupmessage: "Congratulations on the new $ {level}"
Run Code Online (Sandbox Code Playgroud)
因为在 json 中你不能放入 `` 需要做什么才能不只是一个字符串?
我花了大部分时间在这个问题上,但没有答案
错误:
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 : …Run Code Online (Sandbox Code Playgroud)