contextual typing in typescript

Solutions on MaxInterview for contextual typing in typescript by the best coders in the world

showing results for - "contextual typing in typescript"
Ben
27 Mar 2017
1Lets say you defined a call signature for any function.
2
3type greet = (name: string) => void 
4
5Now, when you declare any function having this type, like this
6
7const sayHello: greet = (name) =>{
8  console.log("hello ", name);
9}
10
11you dont need to explicitly annotate funciton paramters and return type,
12  this is called "CONTEXTUAL TYPING".