Transcript
00:00 Alright. Let's get into it. So we've got our composing types from building blocks exercise. Let's create a primitive type, for each one of these. So ID is actually gonna be a string.
00:11 Time stamp will be a number, and email will be a string. K? And then we're gonna use that to create a user type. So type, user, we've got the ID, created at, updated at, email, and we'll have the name just be a string. K?
00:25 But these are basically communicating. This is a special kind of number. You can't just do any number for created at. This needs to be a timestamp, date dot now. I want this to be the current time, the current timestamp.
00:37 This can't just be any string. This has gotta be our proper UUID, like universally unique identifier, whatever. This can't just be any string. It's gotta be an email. This can't just be any string.
00:51 Actually, no, it can because it's a name and who knows what the name is. This doesn't mean that we're actually validating those things. That's a totally separate topic. We're not validating that this is a time stamp or anything. We're just communicating through the variables that we make, to the people who are reading our program to understand what the intent of these things is.
01:10 So here let's do the same thing for a post, that has title, content, and updated at and all of that. So we can reuse those types, for those and then title and content just can be any string. And then, let's just create a couple of samples. So let's create there we go. A user sample and a post sample.
01:30 We'll export both of those, for testing purposes and boom. There we go. The exports and stuff that's mostly for the test, you know, console log isn't gonna be super helpful in this workshop because most of what we're doing is just hovering over this and making sure that, oh, yeah. K. Those types are correct.
01:46 So, it is definitely a, like, relatively common thing to, make a type alias for a primitive like this so that you can communicate effectively what the, intent of each one of these, properties is. Oh, okay. That's a time stamp. I know how to make a time stamp. I'll make one with date dot now, as an example.
02:07 Alright. I hope that was helpful to you. On to the next.
