When discussing programming methods, the webpage here provides useful information.
In Typescript, you have the flexibility to return any value similar to Javascript, and specifying the return type of a function is straightforward.
//example of named functions
function myFunction(): { myMethod: () => number } {
return { myFunction: () => 10 };
}
// example of an anonymous arrow function
const myFunction = (): { myMethod: () => void } => {
return { myMethod: () => { return; } };
}
This should address the specific question at hand.
For further insight into functions, refer to: https://www.typescriptlang.org/docs/handbook/2/functions.html
Regarding a personal preference, you can choose to strictly define function returns or rely on type inference. Personally, I often opt not to strictly type function returns.