A
A
asdasdqwe2022-02-28 18:25:46
typescript
asdasdqwe, 2022-02-28 18:25:46

How to set the type for an array of objects?

interface types {
     ???
}

let arr = [
    { id: 1, quantity: 1 }
]

function fun(someArray:types ) {}

fun(arr )


How can I set the type for this array?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2022-02-28
@asdasdqwe

type T = {
  id: number;
  quantity: number;
}[];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question