Skip to content

Result<T> helpers: unwrap, isOk, isErr, tryAsync #88

Description

@productdevbook

Problem

Users must discriminate the `Result` union manually (`if (result.error) ...`). Missing ergonomic helpers that feel like neverthrow / ts-results but aligned to our shape.

Proposal

`unemail/result`:
```ts
export const isOk: (r: Result) => r is { data: T; error: null }
export const isErr: (r: Result) => r is { data: null; error: EmailError }
export const unwrap: (r: Result) => T // throws if err
export const unwrapOr: (r: Result, fallback: T) => T
export const mapOk: <T, U>(r: Result, f: (t: T) => U) => Result
```

Acceptance

  • 5 helpers with types
  • Documented as "optional ergonomics"

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreCore API, types, middleware pipelinedxDeveloper experience & toolingpriority-mediumValuable when time allowsv1.1v1.1 milestone (shipped)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions