添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Interface for functions in Typescript

Typescript is capable of defining Interfaces for functions. In this tutorial, we will learn how to define an interface for function types and use it.

Creating Interface for Function Types

To create an interface for function type use the keyword interface followed by the interface name. Then follow It up with curly brackets {} . Inside the curly braces { } add the list of parameters (comma-separated) inside parentheses. Follow it up with a semicolon : and return type.

In the following example, the Calculator is an interface that describes a function. The function takes two arguments and returns a number.

Leave a Comment Cancel Reply

Your email address will not be published. Required fields are marked *