I've defined the following interface
:
export interface Data {
visibleAction: string
actionsVisibility: {
actionForms: boolean
backButton: boolean
createAccount: boolean
login: boolean
}
actionsHistory: string[]
userID: string
}
which is later implemented on the class:
export default class userManager extends Vue implements Data {
actionsVisibility = {
login: false,
createAccount: false,
backButton: false,
actionForms: false
}
visibleAction = `login`
actionsHistory = []
userID = ``
hideUserActionForm () {
this.actionsVisibility[this.visibleAction] = false
}
... other logic
}
For the line this.actionsVisibility[this.visibleAction] = false
TS warns with the error:
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ login: boolean; createAccount: boolean; backButton: boolean; actionForms: boolean; }'. No index signature with a parameter of type 'string' was found on type '{ login: boolean; createAccount: boolean; backButton: boolean; actionForms: boolean; }'.
Can you please suggest how approach the followin typecism :)