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

Some improvements #22

Merged
merged 3 commits into from
Dec 10, 2024
Merged

Some improvements #22

merged 3 commits into from
Dec 10, 2024

Conversation

iliaamiri
Copy link
Member

@iliaamiri iliaamiri commented Dec 7, 2024

Fixed

  • Fixed mightFail.all type inference by using the type signature for Promise.all in the ES2015 Promise Constructor instead of Iterator because the former gives tuple level type hinting vs. the latter doesn't.
  • Fix part of the mightFail.any's error type is inaccurate #20 issue with having to cast the error to AggregateError

Changed

  • Removed mightFail.allSettled as it is unnecessary because Promise.allSettled never throws an error.
  • Change the prettier new line to LF because it's what Unix-based systems use vs. CLRF is what Windows uses. And we hate Windows of course.
  • Format some lines based on the prettier config

- remove mightFail.allSettled
- change the prettier new line to lf
- format some lines
@iliaamiri iliaamiri changed the title Addressing [Issue #20](https://github.com/might-fail/ts/issues/20) Addressing Dec 7, 2024
@iliaamiri iliaamiri changed the title Addressing Addressing Issue #20 Dec 7, 2024
@iliaamiri iliaamiri changed the title Addressing Issue #20 Some improvements Dec 7, 2024
@meech-ward
Copy link
Collaborator

does E extends Error = Error mean that it defaults to Error but can be any custom subclass/subtype of error?

why does it not work already with the way Either works?

@iliaamiri
Copy link
Member Author

Yep exactly. The issue was that the exact subtype of Error doesn't infer at all. For example in the Promise.all method, when error happens, the error should be AggregateError but I had to manually cast it myself.

Or just generally when a dev wants to throw a custom Error, they can't see the real type cause the type doesn't infer because we gave a concrete Error type to the Either instead of a generic one.

@meech-ward meech-ward merged commit 8b83ff2 into might-fail:dev Dec 10, 2024
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.

2 participants