Skip to content

refactor(util): decouple Result from Zod#44479

Open
zharinov wants to merge 4 commits into
renovatebot:mainfrom
zharinov:refactor/result-zod-decoupling
Open

refactor(util): decouple Result from Zod#44479
zharinov wants to merge 4 commits into
renovatebot:mainfrom
zharinov:refactor/result-zod-decoupling

Conversation

@zharinov

@zharinov zharinov commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Changes

  • Replace the direct Zod dependency in Result with a structural SafeParser interface.
  • Remove safe-parse-result shape detection and implicit conversion in wrap() and transform().
  • Reject nullable schema output at compile time.
  • Constrain unwrapOrThrow() to Error-typed result channels.
  • Simplify uncaught-error propagation and nullable wrapping overloads.
  • Update the affected Pixi, Poetry, and Rubygems consumers.
  • Update the Result/Zod development documentation.

For optional-field extractors, this adds the nonNullish Zod transform callback:

schema.transform(nonNullish)

Normal Zod integration remains available through Result.parse(input, schema) and .parse(schema).

A parser that claims to return a non-nullish value but produces null or undefined at runtime is now treated as a programmer error and routed through the uncaught-error channel.

Context

Please select one of the following:

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non-trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Fable 5 assisted with planning. GPT-5.6 Sol, used through the Zed coding agent, assisted with implementation, tests, and documentation.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests, but ran on a real repository, or
  • Both unit tests + ran on a real repository

The public repository: N/A

@github-actions github-actions Bot requested a review from viceice July 10, 2026 15:01
@zharinov

Copy link
Copy Markdown
Collaborator Author

I asked SOTA models to analyze existing result-handling libraries in the NPM ecosystem and synthesize the refactor for one that I've written a while a go, to remove ugly parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant