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

pathOr requires two generics, when one makes more sense #416

Closed
ipanasenko opened this issue Oct 12, 2018 · 2 comments
Closed

pathOr requires two generics, when one makes more sense #416

ipanasenko opened this issue Oct 12, 2018 · 2 comments

Comments

@ipanasenko
Copy link

ipanasenko commented Oct 12, 2018

Hey guys.

I'm using pathOr like this:

type TSomeProp = { cc: number; };
type TItem = {
  aaa: TSomeProp[];
};
const item: TItem = {
  ...
};

pathOr<TSomeProp[], TSomeProp[]>([], ['aaa'], item);

It seems that I always need to specify two generics, even if I want default to be the same type as what I get on that path.

Do you think we can make second generic optional?

BTW, I think this also applies to propOr

@ikatyang
Copy link
Member

Unfortunately, it'll cause an unexpected inference for currying due to their type parameter dependencies:

-R.pathOr('N/A')(['a', 'b'], { a: { b: 2 } }) //=> string | {}
+R.pathOr('N/A')(['a', 'b'], { a: { b: 2 } }) //=> string

@ipanasenko
Copy link
Author

Got you, thanks!

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