Еще можно так:
type fruits = {
id: string,
data: string
}
type vegetables = {
id: string,
text: string
}
let arr = [
{id: "1", data: "sadsa"} as fruits,
{id: "2", text: "sdsadsa"} as vegetables,
] as const;
console.log(arr[0].data);
ts playground
Или так:
type fruits = {
id: string,
data: string
}
type vegetables = {
id: string,
text: string
}
let arr: readonly [fruits, vegetables] = [
{id: "1", data: "sadsa"},
{id: "2", text: "sdsadsa"},
];
console.log(arr[0].data);
ts playground