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

combineWithAllErrors doesn't narrow down type of items in list #515

Open
Sebastian-Nielsen opened this issue Nov 28, 2023 · 0 comments
Open

Comments

@Sebastian-Nielsen
Copy link

	if (combineWithAllErrors([ result1, result2, result3 ]).isErr()) {
	        console.log("some error")
		return err();
	}
	
	// We know for sure know that result1, result2, and result3 are ok:
	result1.value; // TS2339: property 'value' does not exist on type 'Result' 
	
	// ^^ it seems typescript doesn't know?

I am forced to do:

	if (combineWithAllErrors([ result1, result2, result3 ]).isErr()) {
	        console.log("some error")
		return err();
	}
	
	if (result1.isErr()) {    
		return 1 as any;
	}
        console.log(result1.value); // works

Can we do something about the fact that combineWithAllErrors doesn't narrow down the type for the items in the provided list?

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

1 participant