Imagine I have a type:
type Foo = {
id: string;
type: 'foo';
}
type RealtionShipT<T extends Foo | Foo[]> = {
data: Pick<T, 'id' | 'type'>; // Do this if T is not an array
data: Pick<T[number], 'id' | 'type'>; // Do this if T is an array
}
For RelationshipT, I need the type to be the top form if T is NOT an array, but the bottom form if T IS an array. How can I do this?