Type inference error when using .andThrough()
When using .andThrough() with a function that returns a Result, TypeScript reports a type mismatch, even though the function signature should be compatible.
part of code
ok({
title: "title",
description: "description",
})
.andThen((s) => ok(s))
.andThrough(assertPublishable) // <= error happen
current return type
Result<{
title: string;
description: string;
}, Error_A>
expected return type
Result<{
title: string;
description: string;
}, Error_A | Error_B>
Curiously, if I comment out .andThen((s) => ok(s)), the error disappears and the return type becomes exactly as expected.
typescript playground is here
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgUylANHCBrOBfOAMyghDgCIA7ZAN1RgAsSB3cgbgCgOBjAGwEMAzoLgBRNNAD6AQRQAPGMkoATEeJJREHOHDBRgNforhRk-ZREq8AnnEkxrYZAC4K6qdPZcd3S4JhQAK7cMNAAFCDIwvwA5i5w-vqUMQCUWjo6goFOUBFRgrHIKZwZcIzAggB09o7IcAC8bhJQMl46eBwdfEJqzZIAQvKKKr0a6br6hsam5pY2dg5OruTuLf1e2nC+lInBobmR0XGuicDJaQibmdmoeUdFJRnlVTVODU0aA234nVzb-nAevQAAqBABGvAqDH4ELqjTCgko-DAggYEBgrkuOhgwBgvHip2Sj2UUW4+jAOMsJwCZxinDwaXqAD5xsBCHAwgBCRHI1Hoyo4vFFcY6UwwQJQSgoNBhajMMR9aRhcioDSeFLFTYdHRsjncpEotEwSokwRk4AU4CWC5XEzIcWS6W5OUKz79ZWq6DrDWPbV2h1SnBhTV4TgcINYsq4-HLQX48joTam82WqkUZPkymUBOdFKbSr8FQAFQYSjCCMZLKDgg1+cLyhLJECMQYYSBsFBEKhMPxmqAA