I have one Basic interface:
interface Basic {
[key: string]: {
data: string;
};
}
Another interface extending it:
interface Another extends Basic {
'onekey': OneKeyData;
'secondkey': SeconKeyData;
}
My issue with is when use generic T extends keyof Another
it allows any string keys because of Basic interface. OneKeyData and SecondKeyData they all contain data
property as in Basic. I would remove extends Basic
if it wasn't used in other place like this:
interface Options<TKey extends keyof Another> {
field: Another[TKey]['data'];
}
What is the best solution in this case? Is it possible to get keyof
only Another
interface?