O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Function type interfaces

We just saw how to define properties in interfaces. Similarly, we can also define function types in interfaces. We can define function types in interfaces just by giving the signature of the function with the return type. Note that in the following code snippet, we have not added the function name:

interface AddCustomerFunc {   (firstName: string, lastName: string); void } 

Now, AddCustomerFunc is ready. Let's define a function type variable, AddCustomerFunc, and assign a function of the same signature to it as follows:

let addCustomer: AddCustomerFunc; addCustomer = function(firstName: string, lastName: string) {   console.log('Full Name: ' + firstName + ' ' + lastName); } 

The parameter name in the function signature ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required