Avatar ·

How to correctly declare an array of objects in TypeScript?

Hi! I just started learning TypeScript and ran into a problem. I'm writing a small task management application. I have an array of objects, each object describes a task: it has a title, completion status, and creation date. In JavaScript I would just write: const tasks = [ { title: 'Buy milk', done: false, createdAt: new Date() }, { title: 'Do exercises', done: true, createdAt: new Date() } ]; But in TypeScript I need to specify the type. I tried different options, but I'm not sure which one is correct and when to use which. I tried this: const tasks: Array = [...]; const tasks: object[] = [...]; const tasks: any[] = [...]; The first option works, but I can't access the title field — TypeScript complains that the property does not exist on type