-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
feat: add isNothing()
#989
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for quizzical-lovelace-dcbd6a canceled.
|
Another thing is, should the Right now I have to access it through |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response! Feature looks good time, as does the test proposal. Would you mind to add the test file indeed, testing both the type inference and runtime behavior of the utility? Thanks!
Sure, do you mind I add |
Also, looking at the PR again, it turns out the type is actually not exported. Will need to fix that. The circular dependency is also an issue. Maybe I can create a different PR to fix all circular dependency issue first, as that would lead to many problems. |
We already use |
I'll check that out. Thx |
@unional were you able to set up some tests? |
Hi, yes I just get back to this. I have tried the // @ts-expect-error
assert(value, _ as Nothing)
// vs
isType.equal<false, typeof value, Nothing>() It works either way. Didn't know about I do found one issue from this PR. I looked up the code and found that it is actually needed by one of the public types already: /** Converts `nothing` into `undefined` */
type FromNothing<T> = T extends Nothing ? undefined : T
/** The inferred return type of `produce` */
export type Produced<Base, Return> = Return extends void
? Base
: Return extends Promise<infer Result>
? Promise<Result extends void ? Base : FromNothing<Result>>
: FromNothing<Return>
So exposing the type should be needed in the first place and that may be an existing bug. However, exposing this But that will need some investigation. |
fix #988
I can add tests, but want to know which file should I add it to. Type guard is TS stuff so maybe I create a new file
__tests__/common.ts
?