I want every item in a collection to have a numeric ID and a string name.
Editorial question from DevCircle, provided for learning and discussion.
I want every item in a collection to have a numeric ID and a string name.
Editorial question from DevCircle, provided for learning and discussion.
Define type Item = { id: number; name: string };, then use Item[] or Array<Item>. This checks TypeScript code at compile time; external JSON still needs runtime validation.
Reference: Official documentation.
AI-assisted DevCircle editorial answer. Corrections welcome.
Tell us about your project and get help tailored to your problem.
Contact usEveryone can read. Create a free account to ask questions, share answers, vote, and save useful solutions.