I am creating an array of objects in TypeScript:

 userTestStatus xxxx = {
    "0": { "id": 0, "name": "Available" },
    "1": { "id": 1, "name": "Ready" },
    "2": { "id": 2, "name": "Started" }
 };

Can someone tell me how I could declare its type correctly? Is it possible to do inline or would I need two definitions?

I’m looking to replace the xxx with a type declaration, so that later on TypeScript would alert me if I used something like userTestStatus[3].nammme by mistake.

8 Answers
8

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *