Reputation: 566
Build an interface that inside will have telephone_array
. I know that my telephone_array
is an array that has many objects inside.
interface Client {
id: string;
name: string;
email: string;
telephone: string;
created_at: string;
}
interface ClientsResponse {
clients: Client[];
}
I would like to know how can I put the telephone_array inside the interface.
Upvotes: 0
Views: 43
Reputation: 14873
Just use another interface as an array:
interface Telephone {
id: string;
telephone_number: string;
}
interface Client {
id: string;
name: string;
email: string;
telephone: string;
created_at: string;
telephone_array: Telephone[];
}
Upvotes: 0
Reputation: 1430
You can add array of objects like so:
interface Client {
id: string;
name: string;
email: string;
telephone: string;
created_at: string;
telephone_array: Array<{
id: string;
telephone_number: string;
}>
}
or
telephone_array: {
id: string;
telephone_number: string;
}[]
Upvotes: 2
Reputation: 11181
Something like this
interface Client {
id: string;
name: string;
email: string;
telephone: string;
created_at: string;
telephone_array: {
id: string;
telephone_number: string;
}[];
}
Upvotes: 1