According to doc https://www.typescriptlang.org/docs/handbook/interfaces.html#function-types
I want to restrict the parameters of a function. I have written my function like this....
interface FuncType {
(one: number, two: number, three: number): number;
}
let myfunc: FuncType = function (num1: number, num2: number, num3: number) {
return num1 + num2 + num3;
}
let result = myfunc(10,20,30);
console.log(result);
This works great. But the problem is, if I do this...
let myfunc: FuncType = function (num1: number, num2: number) { //num3 is missing
return num1 + num2;
}
// let result = myfunc(10,20); //this gives an error.
let result = myfunc(10,20,30); // I had to give three parameters
console.log(result);
This works too. It is not showing any error. I was expecting it should give an error because num3 is not used there in the function definition.
It is also confusing because I cannot call myfunc with two paramters.
Is it not possible to make the function definition strict according to the interface?