-
Notifications
You must be signed in to change notification settings - Fork 24
Infer result type when available in .deserialize #38
Copy link
Copy link
Open
Description
Basically I'm having to do this:
const result = Result.deserialize<
Extract<typeof serialized, { status: "ok" }>["value"],
Extract<typeof serialized, { status: "error" }>["error"]
>(serialized);But even here, because serialized is typed, we don't need to check Result shape and .
In fact ... what I want when my stack has the serialized shape is to just do this:
if (serialized.status === "ok") {
result = new Ok(serialized.value);
} else {
result = new Err(serialized.error);
}So maybe I just want Result.fromSerialized or Result.new?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels