I’m getting the following error when trying to use a dynamic value for an array key.
Element implicitly has an 'any' type because expression of type '`faults_${string}`' can't be used to index type 'HeatsTable'.
export interface HeatsTable {
heat_id: UUID
start: number
faults_1: string[]
faults_2: string[]
faults_3: string[]
faults_4: string[]
}
const fault = heatData[`faults_${runningId}`]; // Throws the above TS error
Using keyof HeatsTable
works but causes an error on another page because it thinks faults could be a number. Is there another solution for this that I’m missing?