📜  打字稿代码示例中的上下文输入

📅  最后修改于: 2022-03-11 14:48:18.691000             🧑  作者: Mango

代码示例1
Lets say you defined a call signature for any function.

type greet = (name: string) => void 

Now, when you declare any function having this type, like this

const sayHello: greet = (name) =>{
  console.log("hello ", name);
}

you dont need to explicitly annotate funciton paramters and return type,
  this is called "CONTEXTUAL TYPING".