You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the new AR functions, we've run into a scenario when calling AR.toOption on a promise that has resolved undefined will result in the underlying value being { BS_PRIVATE_NESTED_SOME_NONE: 0 } (where O.None would instead be expected).
For example:
consttoOptionTest=async()=>{constoption=awaitpipe(AR.resolve(undefined),AR.toOption);console.log('option is:',option);O.match(option,()=>{console.log('option is `Some`');},()=>{console.log('option is `None`');},);returnoption;};voidtoOptionTest();
In the above, option is inferred by the Typescript compiler to be O.Option<undefined>, however the following is printed:
2023-12-06 09:15:04 option is: { BS_PRIVATE_NESTED_SOME_NONE: 0 }
2023-12-06 09:15:04 option is `Some`
I would instead expect the "option is `None`" log line to be printed, and the someFn branch of O.match not to have been called.
This appears to be an underlying Rescript value which is returned by AR.toOption because Some(value) is called here even if the value is None:
When using the new
AR
functions, we've run into a scenario when callingAR.toOption
on a promise that has resolvedundefined
will result in the underlying value being{ BS_PRIVATE_NESTED_SOME_NONE: 0 }
(whereO.None
would instead be expected).For example:
In the above,
option
is inferred by the Typescript compiler to beO.Option<undefined>
, however the following is printed:I would instead expect the "option is `None`" log line to be printed, and the
someFn
branch ofO.match
not to have been called.This appears to be an underlying Rescript value which is returned by
AR.toOption
becauseSome(value)
is called here even if the value isNone
:ts-belt/src/AsyncResult/AsyncResult.res
Lines 70 to 72 in c825d97
The text was updated successfully, but these errors were encountered: