interface User extends Function {
player: number,
units: number[],
sites: string[],
}
class User extends Function {
constructor() {
super('return this.player')
[this.player, this.units, this.sites] = getBelongings(); // Destructuring Assignment
}
}
const me = new User();
function getBelongings(): [number, number[], string[]] {
return [1, [1], ['1']]
}
The scenario above looks promising, and I am confident that my code is correct.
However, an error message appears:
Type 'string[]' cannot be used as an index type.(2538)
I have used destructuring in the past without issues, so I am unsure why this problem is happening now.
Could it be a TypeScript issue or a mistake in my syntax? How can I resolve this and ensure smooth operation of the code? Thank you for your assistance.