Cristi
Member since Nov 15, 2018
- Profile: /members/13832-cristi.htm
- Comments: 3
Recent Blog Comments By Cristi
-
Using Method And Function Overloading In TypeScript
Posted on Nov 29, 2018 at 5:19 AM
@Ben, function myCallback( value: string ) : string; function myCallback( value: number ) : number; function myCallback( value: number | string ) : number | string { // function implementation } This is exactly what I was looking for, I did not know about this syntax. It's not m... read more »
-
Using Method And Function Overloading In TypeScript
Posted on Nov 26, 2018 at 8:52 AM
@Ben, The issue seems to be on the return type and not the parameters, because if I implement the method with return type any , it will work: const numberOrString: NumberOrStringMethod = (input: string, type: 'string' | 'number'): any => { return type === 'string' ? input : +... read more »
-
Using Method And Function Overloading In TypeScript
Posted on Nov 15, 2018 at 3:28 AM
This is a really nice article. One question though, do you also have an example for function overload, as currently in the example, you show only for methods (function belonging to a class). I'm interested to overload an actual function and I tried it with an interface but it fails for the ... read more »