Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'User_Economy'

Ошибка: 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:User_Inteface = {//code} 
    const type: keyof User_Economy = ['level', 'money', 'rep', 'xp'].find(x => {
                return typed.toLowerCase() === x
            })
    data.Economy[type] += Math.floor(parseInt(amount));

Ответы (1 шт):

Автор решения: KristalkillPlay

Ответили мне на Англиском стаке, если кому нужно будет, то решение проблемы простое:

const types = (['level', 'money', 'rep', 'xp'].find(x => {
            return typed.toLowerCase() === x
        })) as Exclude<keyof User_Economy, 'box'>

Exclude исключает из интерфейса User_Economy, параметер box

→ Ссылка