Handling Undefined in Promise with Effect.filterOrFail in TypeScript

This should be extremely simple but I'm definitely just missing something.

I have a tryPromise which has a function that returns Promise<Data | undefined>, I want to stop the pipe with a Effect.Fail when it is undefined.

For some reason Effect.filterOrFail doesn't really seem to work though, I have tried may different ways, here's one of them to give a better idea of what I'm talking about:

 Effect.bind("aaa", ({ values }) =>
        pipe(
          Effect.tryPromise(() =>
            something.whichCanThrowOrReturnUndefined(values.someValue),
          ),
          Effect.filterOrFail((x) => x !== undefined),
        ),
      ),


The result of aaa is always still Data | undefined, also swapping the logic around has the exact same result so I'm definitely doing something wrong here :p
Was this page helpful?