Having two different key types, OneOf
and FeildType
, to distinguish between the two types, I initially tried creating the following type but it ended up combining the member types.
interface TypeMap {
[key: number]: FeildType
[key: string]: OneOf
}
Attempting to merge the two keys into one member like this:
interface TypeMap
[key in (number | string)]: key extends string ? OneOf :
key extends number ? FeildType :
never
}
Unfortunately, this also resulted in the merging of the two types.
Is there a way to define this type without combining the member types, like so:
interface TypeMap {
[key: number]: FeildType
[key: string]: OneOf
}
Can this be achieved without merging the two member types?