Skip to content

equals and union type #268

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

Open
wclr opened this issue Oct 4, 2017 · 4 comments
Open

equals and union type #268

wclr opened this issue Oct 4, 2017 · 4 comments

Comments

@wclr
Copy link
Contributor

wclr commented Oct 4, 2017

type Union = 'one' | 'two' | 'tree'

const fn = (union: Union) => {
  union === 'four'
  R.equals('four')(union)
  R.equals('four', union)
  R.propEq('prop', 'four', { prop: union }) 
}

image

What do you think, should/can equals error on this?

@wclr wclr changed the title equals (equal and union type equals and union type Oct 4, 2017
@KiaraGrouwstra
Copy link
Member

KiaraGrouwstra commented Oct 4, 2017

I'm with you, though this is a TS thing, rather than one on Ramda typings.
I actually made a PR at TS arguing exactly this, though the TS team saw things differently. If you have a good use-case, please tell them about it.

@wclr
Copy link
Contributor Author

wclr commented Oct 4, 2017

Well I believe this one is a valid case =)

@KiaraGrouwstra
Copy link
Member

Whoops, I'm wrong, that issue was specifically about generics. I vaguely recall another issue about this more general case, but no clue where it was...

@KiaraGrouwstra
Copy link
Member

Uhh, not sure if there is an issue for this there, so feel free to create one. Fortunately it's an easy change (just widen the types where I currently did getApparentType here) -- the question is mainly where they'd want it.

Given that change, I imagine my PR might gain more utility as well. I'm not fully awake yet, but in the present logic (not resolving generics) I'm not sure atm how it allows comparing say a literal (e.g. 0) and a generic (bound to e.g. number), though that should be fine. .. Then again I don't recall it actually being that picky currently. Hm.

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