Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v1.25.1 #205

Merged
merged 5 commits into from
Dec 21, 2024
Merged

Release/v1.25.1 #205

merged 5 commits into from
Dec 21, 2024

Conversation

4lessandrodev
Copy link
Owner

[1.25.1] - 2024-12-20

Feat

  • Dynamic Typing in Result Made Optional:
    • Developers can now choose between Result<T> (non-nullable) and Result<T | null> (nullable), based on their specific use case.
    • This update allows greater flexibility for explicit null handling without forcing unnecessary complexity in scenarios where nullability is not required.

Examples

  1. Explicit Null Handling:
    Use Result<T | null> to manage nullable states explicitly:

    class SampleNullish {
        public static create(props: Props): Result<SampleNullish | null> {
            if (!props.name || props.name.trim() === '') {
                return Fail('name is required');
            }
            return Ok(new SampleNullish(props));
        }
    }
  2. Non-Nullable Values:
    Use Result<T> for cases where null handling is unnecessary:

    class Sample {
        public static create(props: Props): Result<Sample> {
            if (!props.name || props.name.trim() === '') {
                return Fail('name is required');
            }
            return Ok(new Sample(props));
        }
    }

Fix

  • Enhanced backward compatibility by making nullable typing optional, ensuring existing integrations using Result<T> remain unaffected.

Impact

  • Improved Flexibility:
    Developers can adapt the Result type to suit their needs, supporting nullable and non-nullable use cases seamlessly.

  • Enhanced Clarity:
    Provides explicit type inference, ensuring safer and more intuitive code handling for nullable scenarios.

#194

@4lessandrodev 4lessandrodev merged commit 9b790be into main Dec 21, 2024
1 check passed
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