Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an AsyncResult.andThen fix-related regression (#195)
This patch reverts commit [1] and documents this fact. The problem is after [1] the following code const fromRegularResult = (Ok(1) as Result<number, string>).toAsyncResult(); fromRegularResult.andThen((value) => Ok(value * 2)); would fail co compile: src/file.ts:169:19 - error TS2349: This expression is not callable. Each member of the union type '{ <T2>(mapper: (val: never) => Ok<T2> | Promise<Ok<T2>> | AsyncResult<T2, never>): AsyncResult<T2, string>; <T2, E2>(mapper: (val: never) => Result<...> | ... 1 more ... | AsyncResult<...>): AsyncResult<...>; } | { ...; }' has signatures, but none of those signatures are compatible with each other. 169 fromRegularResult.andThen((value) => Ok(value * 2)); ~~~~~~~ src/file.ts:169:28 - error TS7006: Parameter 'value' implicitly has an 'any' type. 169 fromRegularResult.andThen((value) => Ok(value * 2)); ~~~~~ I spent the last Friday's afternoon trying to figure out why and how to fix it and I failed. I think reverting the original patch is the way to go for now and it was handling an edge case anyway. It's more important that andThen works in general cases (where the callbacks return Result, not always Ok). [1] 9259f83 ("Fix the AsyncResult.andThen handling of known-Ok transformations (#189)")
- Loading branch information