-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make isEmpty
a type guard
#16
Comments
@yokuze This is easy for |
I don't think we need to differentiate between empty vs non-empty By far, the most frequent pain point that we are trying to solve by making this function a type guard is something like this: function doSomething(withThis: string | undefined): void {
if (isEmpty(withThis)) {
} else {
// TypeScript should at least know here that `withThis` not `undefined`
}
} Anything beyond that is extra credit IMO. That said, I may be missing something, so let me know if there's a use case you think we should support by differentiating between empty vs non-empty interface IEmptyArguments extends IArguments {
length: 0;
} |
Currently,
isEmpty
just returns aboolean
. It would be much more useful if it were a type-guard that asserted that its parameter was one of the "empty" object types its checking for.The text was updated successfully, but these errors were encountered: