Add this context support to safeTry function#658
Open
yasaichi wants to merge 6 commits intosupermacro:masterfrom
Open
Add this context support to safeTry function#658yasaichi wants to merge 6 commits intosupermacro:masterfrom
this context support to safeTry function#658yasaichi wants to merge 6 commits intosupermacro:masterfrom
Conversation
- Add overloads for safeTry to accept `this` context as first parameter - Support both sync and async generators with proper type inference - Maintain backward compatibility with existing API - Implement GitHub issue supermacro#632 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add tests for sync/async generators with this context - Tests mirror existing test structure for consistency - All 121 tests passing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add example usage of safeTry with this context in class methods - Use async generator example demonstrating this binding - Use type inference approach for cleaner code examples 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove explicit type parameters from examples to rely on type inference - Fix async generator return type from Promise<Result> to ResultAsync 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Author
|
@supermacro What can I do for you to merge this PR? Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements support for passing
thiscontext to the generator function insafeTry, following the established pattern already implemented in similar libraries like Effect and typescript-result.Closes #632
Usage
Why This Matters
This feature enhances the ergonomics of
safeTrywhen used in class-based designs, eliminating the need for manual binding to preserve context (e.g.that). This brings neverthrow in line with other modern Result/Effect libraries that have already adopted this pattern.