Skip to main content

Cristi

Member since Nov 15, 2018

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 »

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel