D
D
driver4582018-09-19 18:57:17
typescript
driver458, 2018-09-19 18:57:17

How to describe an object (array) in typescript?

How to describe an object in typescript which is essentially an array of objects of the same type, but with access not by index but by key?

interface ItemI {
  name: string;
}

interface DataI {
  items: ? // object of ItemI
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Lopatin, 2018-09-19
@driver458

interface DataI {
  items: { [key: string]: ItemI };
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question