From the course: TypeScript Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: Types

Solution: Types

(upbeat music) - [Instructor] In this challenge, I showed you a JavaScript application that had just been converted to TypeScript but lacked any kind of additional type information. And I asked you to give it that type information. Here's how I solved this challenge. First, I asked you to create an interface to describe the structure of this variable on lines one through five. The way I would approach this is, first, come up with a name. What are we looking at here? It's an array of to-do items. So I'm going to call my interface something like to-do item or just to-do. Next, I'm going to take a look at what is similar and what is different in these items. They all have an ID that's a number, a title that's a string, and a status that's also a string. Also, one of them has a completed on property, which is a date value, however, this is not always present on all to-do items. So I'll make this one optional. Then,…

Contents