Difference between call signature and function type

They are exactly the same.

why do we need two different yet so similar ways to write the same thing in typescript

The (x:number, y:number)=>number signature is useful as a property annotation :

interface MyInterface {
    (x:number, y:string):string;   
    someProperty: (x:number, y:number)=>number;
}

Which is similar to your:

var myTwo : (x:number, y:number)=>number

Just a shorthand for a verbose :

var myTwo : {(x:number, y:number):number}

So you can see the simplicity of ()=>.

Also

One thing to note is that a function signature allows overloading:

var myTwo : {
    (x:number, y:number):number;
    (x:number):string;
}

Which is not supported for a property annotation.

Leave a Comment