How to convert a string to number in TypeScript?

Exactly like in JavaScript, you can use the parseInt or parseFloat functions, or simply use the unary + operator: All of the mentioned techniques will have correct typing and will correctly parse simple decimal integer strings like “123”, but will behave differently for various other, possibly expected, cases (like “123.45”) and corner cases (like null).  Table taken from this answer

How can I define an array of objects?

You are better off using a native array instead of an object literal with number-like properties, so that numbering (as well as numerous other array functions) are taken care of off-the-shelf. What you are looking for here is an inline interface definition for your array that defines every element in that array, whether initially present or introduced later: If … Read more