In TypeScript, one of the most difficult types to declare is a function. It can get very complex in a just simple concatenation of the functional chain.
Declaring a function in TypeScript is a composition of the parameters that the function will receive and the final type that the function will return.
You can declare a simple function inside a constant, like this:
const sumOfValues: (a:number, b:number): number = (a: number, b: number): number => a + b;
A more complex function declared inside a constant can be declared like this:
const complexFunction: (a: number) => (b:number) => number = (a: number): (b: number) => number => (b: number): number => a + b;
When declaring a function as a normal function, the way to type it is almost the same as in a constant way, but you don't need to declare that the functions are a function. Here is an example:
function foo(a: number, b:number): number{
return a + b;
}