Introduction to TypeScript. Function Types (opens in new tab)
Basic syntax Since everything in TypeScript has to have type, functions are also wrapped in the type system: inputs must have types, output must have one, let's look at the example: function add(x: number, y: number): number { return x + y; } console.log(add(1, 3)); //4 Actually, we don't have to explicitly assign type for an ouput: function add(x: number, y: number) { return x + y; } console.log(add(1, 3)); //4 The compiler won't see any problem with it, since it implicitly set number type f...
Read the original article