const minimalRepro = <A, E>(
fn: () => AsyncResult<A, E>
): AsyncResult<A, E> => {
return Result.gen(function* () {
const r = yield* fn();
return Result.ok(r);
})
}
Type 'AsyncResult<ExtractValue<Ok<A>>, E | InferError<Ok<A>>>' is not assignable to type 'AsyncResult<A, E>'.
Type 'ExtractValue<Ok<A>>' is not assignable to type 'A'.
'A' could be instantiated with an arbitrary type which could be unrelated to 'ExtractValue<Ok<A>>'. (ts 2322)
Type '[A] extends [never] ? AsyncResult<A, E> : [A] extends [Generator<unknown, any, any> | AsyncGenerator<unknown, any, any>] ? AsyncResult<...> : [...] extends [...] ? PValue extends A ? AsyncResult<...> : never : A extends A ? AsyncResult<...> : never' is not assignable to type 'AsyncResult<A, E>'.
Type 'AsyncResult<A, E> | ([A] extends [Generator<unknown, any, any> | AsyncGenerator<unknown, any, any>] ? AsyncResult<InferGeneratorReturn<A>, E | InferGeneratorError<...>> : [...] extends [...] ? PValue extends A ? AsyncResult<...> : never : A extends A ? AsyncResult<...> : never)' is not assignable to type 'AsyncResult<A, E>'.
Type '[A] extends [Generator<unknown, any, any> | AsyncGenerator<unknown, any, any>] ? AsyncResult<InferGeneratorReturn<A>, E | InferGeneratorError<...>> : [...] extends [...] ? PValue extends A ? AsyncResult<...> : never : A extends A ? AsyncResult<...> : never' is not assignable to type 'AsyncResult<A, E>'.
Type 'AsyncResult<InferGeneratorReturn<A>, E | InferGeneratorError<A>> | ([A] extends [Promise<infer PValue>] ? PValue extends A ? AsyncResult<...> : never : A extends A ? AsyncResult<...> : never)' is not assignable to type 'AsyncResult<A, E>'.
Type 'AsyncResult<InferGeneratorReturn<A>, E | InferGeneratorError<A>>' is not assignable to type 'AsyncResult<A, E>'.
Type 'E | InferGeneratorError<A>' is not assignable to type 'E'.
'E' could be instantiated with an arbitrary type which could be unrelated to 'E | InferGeneratorError<A>'. (ts 2322)
Example 1
Expected behavior
This should compile
Actual Behavior
Example 2
Expected Behavior
This should compile
Actual Behavior