Now I mentioned that interfaces are used to define the structure of an object.
Now interfaces can all be used to define the structure of a function.
So basically as a replacement for the function types you already learn about just as a quick refresher
we can define the type of a function.
For example with a custom type with the type keyword at f n for add function which then could hold a
function definition like this.
It should return a number and it should take two arguments where each argument also is of type number.
Now we could create a new function add here which is of type at f n and when we don't initialize it
but assign our function later then of course we have to make sure that this function takes two arguments
which are of type number and that in there we all return a number.
This is something we can do.
This is what you already learned.
Now you can also use an interface as an alternative to this custom type interfaces are there to define
the structure of an object as it taught you.
But in the end functions are just objects and therefore this is a little exception.
You can create function types with interfaces for Dad you create an interface name it add if and to
still keep that name here and now in there.
You defined a bit of function by just adding parentheses with your arguments a number B number for example
and then a colon not an arrow but a colon here with the return type.
So in the end like you would define a method as we're doing it here with Grete with the exception that
we're now not adding a method name.
So we have an anonymous function if you want to call it like this in the at f an interface and typescript
understands this special syntax off this anonymous function in your interface and understands that you
want to use this interface as a function type and this is how your function should look like.
So now we can use ADF and here and indeed if I would try to accept a string here we would get an error
because this is not a sizeable we need to have a number instead of a string.
So it's simply an alternative to this custom type of course here.
I would argue using a custom type is probably a bit more common.
It's all a bit shorter but it's a nice alternative syntax to be aware of especially if you encountered
as in some project and your other wise lost.
What this means.
This strange anonymous method.
Well it's in the end just a custom function type.