Designing Your Types
Designing your types is a non-trivial task, because your types represent your business logic and domain.
For example, if you're developing an application for car sales, you'll likely need types or interfaces for Car
, Model
, Product
, and Order
among others.
Your types will likely correspond
Transcript
00:00 This section is called Designing Your Types. And designing your types in TypeScript is a non-trivial task, because your types really represent your business logic and your business domain. If you have, I don't know, if you're selling cars, let's say, you probably need a car type or interface. You probably need a product interface,
00:18 probably need an order interface. And you should be thinking about these types as if they're kind of like database entries. And often they will map pretty closely to database entries as well. But you should also be thinking about the way that your types express your logic in your app too. As we'll see in this section, types can contain other types.
00:37 You can compose types together. And when you think about that, you can start to picture how those work. We've already got a lot of tools for that. So we've already got like Interface Extent, where you can build small interfaces and build bigger ones out of those. We've got like Pick and Emit. And we also know that you need a single source of truth
00:56 for most of your types too. And so we're gonna build on that and look at some more complicated methods you can use to build out your types further. But if you start from the idea that you're really, you're just trying to model your business domain in your types, then that's a really sensible place to start.