[Typescript] What is a Function Type ? Function Types and Interfaces

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
}
原文地址:https://www.cnblogs.com/Answer1215/p/6384819.html