Uh oh!
There was an error while loading. Please reload this page.
feat: add isNothing() - #989
Conversation
✅ Deploy Preview for quizzical-lovelace-dcbd6a canceled.
|
unional
commented
Oct 30, 2022
Another thing is, should the Right now I have to access it through |
mweststrate
left a comment
There was a problem hiding this comment.
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!
unional
commented
Jan 2, 2023
Sure, do you mind I add |
unional
commented
Jan 3, 2023
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. |
mweststrate
commented
Jan 3, 2023
We already use |
unional
commented
Jan 4, 2023
I'll check that out. Thx |
mweststrate
commented
Jan 15, 2023
@unional were you able to set up some tests? |
Hi, yes I just get back to this. I have tried the // @ts-expect-errorassert(value,_asNothing)// vsisType.equal<false,typeofvalue,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` */typeFromNothing<T>=TextendsNothing ? undefined : T/** The inferred return type of `produce` */exporttypeProduced<Base,Return>=Returnextendsvoid
? Base
: ReturnextendsPromise<infer Result>
? Promise<Resultextendsvoid ? 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. |
unional
commented
Dec 22, 2025
Updated branch and code. Added directly to |
coveralls
commented
Dec 22, 2025
Pull Request Test Coverage Report for Build 20424962423Details
💛 - Coveralls |
unional
commented
Dec 22, 2025
Want to share that since v10 of using symbol, it has a drawback of not able to distribute the union type with typeUpdater=(s: any)=>number|typeofNOTHING|Promise<number|typeofNOTHING>// error hereconstu: Updater=async()=>NOTHINGType 'Promise<symbol>' is not assignable to type 'number | unique symbol | Promise<number | unique symbol>'.
Type 'Promise<symbol>' is not assignable to type 'Promise<number | unique symbol>'.
Type 'symbol' is not assignable to type 'number | unique symbol'.ts(2322)An explicit type declaration is needed: constu: Updater=async(): Promise<typeofNOTHING>=>NOTHINGI believe this is a limitation on TypeScript. |
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?