I'm trying to use the builder pattern to append a type to a union inside the builder. I've been able to do this with classes before, but now I'm using object factory functions instead.
I expect the type of test to be a PromiseMaybe<{ readonly code: "aaa" } | { readonly code: "bbb" }> with both method calls of .check.
When the second .check call at the bottom is removed, the type of test has the correct type information. But when it's present, the type is never. Why does the first call work, but not the second? How do I fix this?