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.

Heterogeneous `combine` typing

See original GitHub issue

Hi. With my understanding, only typing stops combine currently from working with heterogeneous Results, implementation looks ready for them. I just prepared types for combine that works for Result of many types, at least in my tests. Could it be useful for the library?

It will only works for TS 4.0+.


declare function combine<T extends Result<unknown, unknown>[]>(
    resultList: [...T]
  ): CombineResult<T, T>;


type CombineResult<T extends unknown[], U extends unknown[]> = T extends [
  infer Element,
  ...(infer Rest)
]
  ? Element extends Err<unknown, infer ErrH>
    ? Element
    : CombineResult<Rest, U>
  : Ok<
      { [Index in keyof U]: U[Index] extends Ok<infer OkElement, unknown> ? OkElement : never },
      unknown
    >;

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
supermacrocommented, Jan 12, 2021

So this approach did indeed work. Check out the implementation based on the most recent commit to the project:

https://github.com/supermacro/neverthrow/blob/cfd12a9af796b11426f9426fa94795912f103b77/src/utils.ts


I am going to continue working on neverthrow stuff and then post a release once I am done (end of day today).

Also I will keep this issue open to accept feedback on the current implementation on heterogeneous types.

0reactions
supermacrocommented, Jan 13, 2021

Closing this issue, but as always feel free to open a new issue if there’s something you want to discuss / improve / provide feedback on!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Homogeneous vs. Heterogeneous Mixtures — A Comparison
Mixtures are made of two or more substances that are not chemically combined. Heterogeneous mixtures are randomly mixed. Homogeneous mixtures are uniform.
Read more >
Homogeneous and Heterogeneous Mixture | Chemistry
In this animated lecture, I will teach you about homogeneous mixture and heterogeneous mixture.
Read more >
Homogeneous vs Heterogeneous Mixtures - Diffen
The individual components in a mixture retain their identity. Mixtures are of two types: homogeneous and heterogeneous.
Read more >
Chemical Mixtures
A mixture is made when two or more substances are combined, but they are not combined chemically. There are two main categories of...
Read more >
Homogeneous and Heterogeneous Mixtures - CK-12
A heterogeneous mixture consists of two or more phases. When oil and water are combined, they do not mix evenly, but instead form...
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