Interface for a function in TypeScript

An interface can be made not only for an object, but also for a function. To do this, the interface body specifies call signature functions: parameters for the function and their types, as well as the type of the function's result.

Let's look at the following example. Let's make a type using the IMathFunc interface. In parentheses, we specify two numeric parameters. We specify a boolean type for the return value:

typescriptinterface IMathFunc {
  (num1: number, num2: number): boolean;
}

Now let's make a function myFunc based on our interface:

typescriptlet myFunc: IMathFunc = function(num1: number, num2: number): boolean {
  if(num1 == num2) {
    return true;
  } else {
    return false;
  }
}

console.log(myFunc(2, 2));
Задание 1

Create an interface for a function that takes two strings as a parameter and returns these strings separated by a space.

Задание 2

Create an interface for a function that takes a number as a parameter and returns an array of divisors of that number.

Задание 3

Create an interface for a function that takes a string as a parameter and returns an array of words from that string.