I am looking for a way to ready an element from a json object which should be an Array of type category like
const { categories: Array<Category> } = response.data
// or
const { categories: Category[] } = response.data
Is it possible?
I believe this is what you are looking for.
const { categories } : { categories: Array<Category> } = response.data
response or at least data with a full interface if multiple properties. function someFunction(response: Response & { data: SomeInterface }) {}. The higher up you type data, the better TS can infer types and catch mistakes.