question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Result.combine is broken for array types that are not tuple types

See original GitHub issue

Since 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:closed
  • Created 10 months ago
  • Reactions:5
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
incetarikcommented, Nov 13, 2022

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.

1reaction
ghost91-commented, Nov 13, 2022

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 😕

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found