[Typescript] What is a Function Type ? Function Types and Interfaces - Are They Related ?

Function Type:

type messageFn = (name: string) => string;

function sayHello(name: string): string {
   return `hello ${name}`
} 

const sayHello: messageFn = sayHello;

 

Interface:

interface messageFn {
  (name: string): string
}

 

posted @ 2017-02-10 03:26  Zhentiw  阅读(142)  评论(0编辑  收藏  举报