Post

TypeScript Function Overloading I used to overload functions where I merge the different parameter names and types into one implementation signature like `startOrLength`. But it get's really messy with more than 2 params. The usage of rest args offers a really nice alternative. /

The length of the rest args acts like a discriminator of the signature. If the function is called with one parameter it's the first signature, two parameters for the second signature, and so on.

0 reposts1 like

No replies yet.