I got an error : TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ name: string; isLandlocked: boolean; }'. No index signature with a parameter of type 'string' was found on type '{ name: string; isLandlocked: boolean; }'.
My code looks like:
//some array
const questions: {name: string, quest: string}[] = [
{name: "Is the square blue?",
quest: "isBlue"}
]; //there's gonna be more elements in this array eventually
(...)
//my state
this.state = {
colorsList: colors.map(value => (value.name)),
questionIndex: Math.floor(Math.random() * questions.length),
};
(...)
//handle click on answer button (let's say we always use "no")
handleAnswer() {
let questionValue: string = questions[this.state.questionIndex].quest;
this.setState(color=> ({colorsList: state.colorsList.filter((value) =>
!states[states.findIndex(element => element.name === value)][questionValue])}))
}
(...)
//the button
<button id="no" onClick={this.handleAnswer}>NO</button>
Can somebody help me please ?