I have the following situation: I have type with the following definition:
type A<year extends number> = `a${year}`
And I want to have an interface or a type such that, it has a variable amount of A<year> as keys as required properties and some other properties. For example:
interface AStatistics<years extends number[]>
extends Record<A<year0> & A<year1> ..., number>
& {
aCommonProp: string
}
How can this be achieved?
I don't know if you can achieve it with interface, but you can use indexed access types like this:
Link to playground.