In this video, there's one last quick thing I want to mention, and that is one very special type that
we haven't really discussed too much except in kind of passing.
So at the bottom of this file, I want you to find one more function.
I'm going to define a function called logger.
This thing is going to take some message.
That is a string.
And then inside the function, I want you to just console log that message like so.
So the only goal of this function is to call console log, and it does not actually return any value.
So there's no return statement inside of here to annotate this fact as a return type.
We'll put on Colen void like.
So it's a void right here means that we have a function that's going to not return anything.
Technically, a function that returns void can return null.
And it can also return undefined, but effectively we use void right here to say there will be no return
value from this function if we ever accidentally return something like so.
Well, very quickly get an error message that says, hey, you can't return anything at all.
Now, there's one other very special type associated with function return values as well.
So I'm going to make one more function in here called throw error and throw ER will also take a message
that is a string.
And then any time we call this, I'm going to immediately throw a new air with that message like so.
And just, you know, any time you throw an error, the function will technically not actually return
anything.
So to indicate that we could put on a Colen right here that says never, and that means that we are
never going to actually reach the end of this function.
So we're never going to execute the function completely at some point in time inside of here, we're
going to throw an error and exit the function early without returning any value.
Now, this is a really big court case, it's actually pretty darn rare that we're going to want to,
like, intentionally throw in air like this, it's much more common for us to have some, like, actual
return value in here, like, let's say if there is no message for some reason.
Then we will throw in air.
And then otherwise, we'll return like a. maybe just a message like so and so in this case, we would
still imitate this as returning a string, even though it throws an error.
So we only annotate a function with the type never when we really, truly never expect a function to
return anything ever.
If we at least expect it to return something eventually and only possibly through an error, that's
totally fine.
We're still going to annotate it with whatever we expect it to eventually return.
And that does include the case where we return.
Nothing like so.
So in this case, we would still do a fallback to void because we are technically not returning anything
and there's just a chance of us never reaching the end of the function.
OK, so that's pretty much it.
Let's take a quick pause right here and move on to our next subject.