Fixing TypeScript Implicit Any0:08
Okay, before moving on, I wanna take just a little side quest to handle some of the like outstanding errors in this component. So, uh, these are the, the final two errors in this component right now. And they are handler methods for the form and the form fields. And the thing that TypeScript is complaining about is we have this implicit any type. And if you remember, we don't want an implicit any,
have this implicit any type. And if you remember, we don't want an implicit any, if it can't figure it out, we should specify something. You can still specify any if you really wanted to, but we might as well get a little more specific about it. So let's look at where these are actually being used. So if we come down to handle submit, we can see that this is the form on Submit handler. Now there's a couple ways to figure out what this type should be.
Typing the Submit Handler0:47
Now there's a couple ways to figure out what this type should be. Uh, you can drill down in here and you can say on submit is this form event handler. And you can drill down to that and you can say, eventually we're getting down to this. It gets a little funny. But if you do it just in line for a second and you say, E, you can just hover this and now you can see form event, H, tm, L form element,
and you say, E, you can just hover this and now you can see form event, H, tm, L form element, that's the type you need. So you just need to specify that type up here. This is a little tedious, a little annoying, but it does make everything a little bit tighter and a little more error proof. So let's come back up here and we will say form event. And we're pulling that in from React and it's HTML form element.
And we're pulling that in from React and it's HTML form element. Great. So now that's happy and it actually knows more about, um, exactly what's coming through. So you know that preventive default is a thing you can call and you get all of this extra goodies now because it knows more about that particular parameter. Okay, so let's do the same thing here. So we have the same problem implicit any type,
Typing the Change Handler1:47
Okay, so let's do the same thing here. So we have the same problem implicit any type, and we're gonna hook go down to handle change. And we're gonna see what this looks like here. This is the easiest way that I typically know how to do this. So I hover here, we have a change event for an H, TM L input element. Okay, so let's come back up and we will say change event,
Okay, so let's come back up and we will say change event, and we'll bring that in for an HTML input element. Okay, so now we're happy. We also know that this is a string, this is also a string. The type is also a string and checked is a bullying. So we now have so much more information about what exactly is going on here. So we've tightened that up, we fixed those particular errors,
Wrapping Up Error Fixes2:32
So we've tightened that up, we fixed those particular errors, and now, uh, we can move on to the next thing.
