Seeking to incorporate different types into existing code.
In the code, there exists a transitionData
object in which objects can be added by index as shown below:
this.transitionData[id] = transition
where id
is a number
and transition
is of type Transition
.
Alternatively, it could be:
transitions[t].timer.stop()
Here, t
is a string and timer
is of type Timer
.
The desired interface is as follows:
export interface TransitionData {
[index: number]: Transition
[key: string]: {timer: Timer}
}
However, TypeScript raises an issue with this setup:
Numeric index type 'Transition' cannot be assigned to string index type '{ timer: Timer; }