Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
underscore max and min with empty collections #1513
I'm not sure function overloading would do it, but feel free to show me how if I'm wrong. Here's what I was thinking.
The current type for
But TypeScript doesn't support union types like that. If it kept track of whether a collection was empty or not, you could have an overload like this:
But it doesn't AFAIK. So the only correct option I can think of is this: