The void
type represents the absence of having any type at all. It’s commonly used to indicate that a function does not return a value. When you declare a function with a void
return type, it means that the function doesn’t return anything.
Example
function log(message: string): void {
console.log(message);
}
In this example, the log
function takes a message
parameter of type string
and returns void
, meaning it doesn’t return any value.