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

Improve match return types inference #90

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Improve match return types inference #90

merged 1 commit into from
Dec 18, 2024

Conversation

zoontek
Copy link
Contributor

@zoontek zoontek commented Dec 18, 2024

Fixes #89

I'm not a fan of the naming (B1, B2, etc.), but not a fan of the initial naming too (A, B).
But maybe is that OK for you? It could also be:

match<SomeReturnType, NoneReturnType = SomeReturnType>(
  this: Option<Value>,
  config: {
    Some: (value: Value) => SomeReturnType;
    None: () => NoneReturnType;
  },
): SomeReturnType | NoneReturnType {}

It will be verbose, but clearer.

@zoontek zoontek requested a review from bloodyowl December 18, 2024 09:24
@bloodyowl bloodyowl merged commit 062830e into main Dec 18, 2024
1 check passed
@bloodyowl bloodyowl deleted the match-return-types branch December 18, 2024 13:42
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.

Result.match should not assume the same return type from both paths
2 participants