The last thing we need to do is apply a better type to our payload property right here for action than
any, because, again, as much as possible, we want to avoid in any annotation.
So to do so, we're going to make a couple of key factors inside this file.
And I got to be totally honest with you, this is going to be probably the most challenging and confusing
part of understanding how to get Redox entire script to work together.
We're going to take a look at a diagram or two and really understand what it is we need to inside this
file to get a better right here for our payload.
OK, so first thing I want to really clarify is that we have our repositories reducer and inside of
our application right now, there are three kinds of actions that we expect to receive.
The first kind of action we expect to receive is going to look like this.
There will be some kind of object that has a type property that is search repositories.
We are currently handling that case right here.
We might refer to that as our search repositories action, the second kind of action we have to process
it was whenever we get a response back from the NPM API, we're kind of calling that action the search
repositories success action.
And it will be an action.
Looks like this.
So, again, an object that has a type of search repository success and then a payload property as an
array of strings.
And we're handling that case right there.
Then finally, we have search repositories, air that's going to have a type of search repository there,
and then the air that is a string and as you guess, yep, we're handling that exactly right there.
So to better describe these different kinds of actions that are flowing into our reducer, we're going
to create a separate interface to describe each kind of action.
We're going to create one interface to describe this kind of action, another interface for this one
and another interface for this one.
These three interfaces might look a little something like this.
So this is pretty much the same diagram.
I just put it on its side.
We still have search repositories, search repository, success in the air right there.
So for each of these three different kinds of actions, we're going to write out interfaces that look
like this, the first interface is going to say that all actions that are supposed to be search repositories,
actions will always be an object that has a type property.
And that type property is always going to be exactly the string search repositories.
So, again, this is an interface definition right here.
This is not an actual object we're going to write out in our code.
It is going to be an interface.
Then if we were to write out an interface describing the search repository success action, we would
write out an interface that looks like this.
It is an object that has a type property.
There's going to be exactly the string search repositories success.
It's going have a payload that is an array of strings.
And then finally, something very similar down here as well.
So let's go back over to our file, we're going to write out these three exact interfaces and we'll
see how this really helps us out inside of a reducer.
OK, so a little bit of typing we have to do here, I'm going to first begin by deleting the existing
interface we have.
I'm going to write out interface search repositories.
And I'm going to say that in order for some object to satisfy this interface, it must have a tight
property that is exactly equal to the string Zorch repositories.
Our next one is going to be an interface for search repositories, success, action.
I'm going to say that in order to have an object that satisfies this interface, it must have a type.
That is exactly the strain search.
Repositories.
Success, it must also have a payload that is an array of strings.
And then finally.
Zorch repositories air action in order for an object to satisfy this interface, it must have a tight
property.
That is exactly the string, Zorch roupas batteries error and it must have a payload that is a string.
So we now have three different interfaces, one that exactly describes the three kinds of actions that
we expect to eventually process inside of our repositories reducer.
So at this point, I'm not really clear necessarily where we're going with this.
So let's take a quick pause and see why having these three different interfaces is really, really handy.