Current section: TypeScript 59 exercises
Problem

Props

Loading exercise

Transcript

00:00 All right. So we've got our calculator and we're calling it or rendering it in our app a couple of times. But we need to improve the types of this because somebody could absolutely put in a string of two, and that's going to kind of change the behavior a little bit.

00:17 So, yeah, we want to add some type safety to this. And we are going to do this in a couple of steps because we want to just iterate to a really nice solution. For one thing, it would be really nice if we had our operator autocomplete, but we're not getting any suggestions here.

00:33 So we can have like an operator that doesn't make sense and it blows up the whole application. So that would not be awesome. We won't get to that in this step of the exercise, but we will get there eventually. And then, yeah, of course, we want the right and the left to be typed as numbers and all of that.

00:51 So we're going to start with just this portion to take care of that. So you remove that. We're going to get a bunch of errors right here. So your job is to fix those errors with our calculator props.

01:02 You can inline it if you like to, but in our solution here we're doing calculator props as a name just to keep things separate as you're learning this stuff. So we've got plenty to do. I think you'll have a good time. See you when you're done.