Result.combine is broken for array types that are not tuple types
See original GitHub issueSince https://github.com/supermacro/neverthrow/issues/226 has been merged, Result.combine
is broken for array types that are not tuple types:
import { Result } from "neverthrow";
const results: Result<string, string>[] = [];
const result = Result.combine(results); // inferred as Result<unknown, never>, but should be Result<string[], string>
Earlier, I had thought that this was actually related to the TypeScript option strictFunctionTypes
, but it turns out, this is broken even with that option disabled.
Regardless, I see that neverthrow itself currently does not enable strict
or strictFunctionTypes
in its tsconfig.json
, which is probably how this slipped through. I think in this day and age, enabling strict
should be the default to ensure proper type safety, so I would recommend that neverthrow start using it, too 😃
Issue Analytics
- State:
- Created 10 months ago
- Reactions:5
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Releases · supermacro/neverthrow - GitHub
The following fix was implemented to address this issue and ensure that arrays (not just tuples) work with the combine* family of functions....
Read more >Error while trying to destructure an array of possible length 2
You've not declared message as an array; you've declared it as a tuple ( [string] ) and tuples have a fixed number of...
Read more >Lists and Tuples in Python - Real Python
Lists and tuples are arguably Python's most versatile, useful data types. You will find them in virtually every nontrivial Python program.
Read more >Using arrays in Google Sheets - Google Docs Editors Help
An array is a table (consisting of rows and columns) of values. If you want to group the values of your cells together...
Read more >Array methods - The Modern JavaScript Tutorial
The result is a new array containing items from arr , then arg1 , arg2 etc. ... Arrays do not form a separate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I have free time, I think I can fix it pretty easily but I cannot promise. Until then I think the best would be using the previous version instead. As you referred one of the types as incorrectly implemented, therefore you have seen something incorrect, until the time I can come back to this, you can try fixing it or providing a solution to the problem that is marked as solved with that merge, with your own solution.
Also note that this is blocking us from upgrading neverthrow. We have currently pinned the version of neverthrow to
~5.0.0
, because this issue breaks a whole lot of our code… In particular, we would not be able to upgrade in case of a security fix 😕