Onto part B. So this challenge asks learners to add parameter and return type annotations to the same list of functions that they examined in part A. And so this allows for continuity and also makes it a lot easier for learners to compare the different syntaxes. And so, again, with the hints, we direct them to the docs. We want to get them familiar with working in the TypeScript docs. But if that is not enough, then we also provide them with a little breakdown of the syntax. And, again, we're sort of highlighting that the syntax here by saying you are annotating the parameter here the same way that you would in a variable declaration. And then we have this new sort of syntax of having a colon after the parameter and whatever follows that colon is the return type annotation. And so, once again, with those hints and with the help of their mentor, hopefully they arrive at their own solution, which they can compare to our answers that we provide them in the document.
So, at this point we have given them enough information for them to be able to annotate React functional components. Now, obviously, there's a lot more to function annotations, so we could definitely add more things to the previous challenge. For example, we could tell them to refactor their annotations using type aliases or something like that. But, as I said, at this point they have the bare minimum knowledge to be able to annotate React functional components. So, again, for this topic, we're going to want to break up the challenge into multiple parts. So, part A, ask the learners to create an interface that defines the shape of the props in the component. So, again, we want to make sure in the component. We want to make this digestible. We start with a small portion of the task. As you can see here, we have a component called curriculum card. And all it does is it takes in an object which contains a title, a description, and displays that. So if learners get stuck in trying to annotate or in trying to create the interface for the props of that component, we first guide them to the docs. But here we also give them a little clue and we tell them if you're not sure about the shape of the props, how about you take a look at where we're deconstructing the props. That might help you out. And so hopefully with the docs and the hint there, they're able to come up with their answer and come up with this interface here. And also one thing to note is that at some point, maybe in that challenge that we had on the beginning with basics, you should cover interfaces. This should not be the first time that the learners are seeing interfaces. There's just not enough time in this workshop or in this talk to have shown that, but just want to caveat that this should not be the first time that your learners are seeing interfaces.
Cool, so on to part B, which asks learners to annotate the component using either a function type expression or a parameter slash return type annotation. So again, using the same component from part A, this time we provide them with slightly different hints.
Comments