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

caseError fails with Tasks rejected with only one possible type #1

Closed
dggluz opened this issue Aug 23, 2018 · 1 comment
Closed

caseError fails with Tasks rejected with only one possible type #1

dggluz opened this issue Aug 23, 2018 · 1 comment
Assignees

Comments

@dggluz
Copy link
Collaborator

dggluz commented Aug 23, 2018

In this case:

class NoNegativesError extends Error {
	NoNegativesError = 'NoNegativesError';
}

const rejectNegative = (x: number): Task<number, NoNegativesError> =>
	x >= 0 ?
		Task.resolve(x) :
		Task.reject(new NoNegativesError())
;

const aNumber = rejectNegative(9);

const fixNoNegativesError = caseError(NoNegativesError, _ => Task.resolve(0));

const result = aNumber.catch(fixNoNegativesError);

We expect result to be a Task<number, UncaughtError> but it is a Task<number, NoNegativesError | UncaughtError>. If we had:

const aNumber = rejectNegative(9).map(x => x);

the result would have been the expected one.

This bug is associated with caseError and happens only with Tasks rejected with only one type.

@dggluz dggluz self-assigned this Aug 23, 2018
@dggluz dggluz closed this as completed in 60998f1 Aug 23, 2018
@hrajchert
Copy link
Contributor

🎉 This issue has been resolved in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants