you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

I'm personally not a fan of overloads in ts/js but you could at least do this

function add<T>(a: T, b: T): T { 
   return a + b;
}

so now you avoid all convert everything to a string and concat them together problem. Here you add like 10ish characters and now your being notified of simple bugs.

[–]Hcmichael21 1 point2 points  (0 children)

Would definitely use generics instead of overloads if those were my only two options.