Type inference error when using .andThrough()
Author: msickpalerCreated Nov 4, 2025Updated Mar 4, 2026
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 happencurrent 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
Source: supermacro/neverthrow