I want to have an object where the key 0 has the value of type A, but every other number has type B. So far I've tried this:
type o = {
readonly [key: number]: B;
readonly 0: A;
};
But this doesn't work because A isn't assignable to B and B isn't assignable to A. I've also tried this:
type o = {
readonly <keyType extends number>[key: keyType]: keyType extends 0 ? A : B;
};
But this also doesn't work. Does anyone have any idea on how to achieve what I want?