I have 2 types like
interface RowOne {
id: number;
value: number;
median: number;
timestamp: string;
}
interface RowTwo {
supply: number;
pool1: string;
pool2: string;
fee: number;
}
Now I declare one Union Type like
interface Total {
rows: RowOne[] | RowTwo[];
}
As usual, we should have one share field to check that the return type is RowOne
or RowTwo
But now I have one function like const data = getTotal(): Total
, this function will return data follow RowOne
or RowTwo
But when I get data like data.rows[0].supply
it says that
Property 'supply' does not exist on type 'RowOne | RowTwo'.
So for this case, How can I pass this error? Thanks