I am adding return type values to my functions based on comments I have received in a code review and I don't know what to assign the return type to on this function:
function mysteryTypeFunction(): mysteryType {
return function(): void {
console.log('Doing some work!');
};
}
What is the mysteryType for this function?
Typescript will infer the return type, and the easiest way to find out what it infers is to hover over the symbol:
As we can see the return type is () => void
. Which is a function signature of a function with no argument (the ()
part), that returns void
(the => void
part).
function mysteryTypeFunction(): () => void {
return function(): void {
console.log('Doing some work!');
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With