Skip to content
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

isNil Type Guard #2418

Closed
CanKattwinkel opened this issue Jun 20, 2019 · 1 comment

Comments

@CanKattwinkel
Copy link

commented Jun 20, 2019

Is there any particular reason for isNil not having a type guard? isUndefined on the other side has one.

I've stumbled across it repeatedly because my IDE prefers importing nest over lodash. Lodash, on the other hand, has a guard. In a project with strict: true it is a little annoying.

https://github.com/nestjs/nest/blob/master/packages/common/utils/shared.utils.ts

Current:

export const isNil = (obj: any): boolean => isUndefined(obj) || obj === null;

Wanted:

export const isNil = (obj: any):  obj is null | undefined => isUndefined(obj) || obj === null;
kamilmysliwiec added a commit that referenced this issue Jun 22, 2019
@kamilmysliwiec

This comment has been minimized.

Copy link
Member

commented Jun 22, 2019

Added in 6.3.2 :) Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.