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

TS: Incorrect signature of R.values #119

Closed
lisumio opened this issue Aug 22, 2022 · 2 comments
Closed

TS: Incorrect signature of R.values #119

lisumio opened this issue Aug 22, 2022 · 2 comments

Comments

@lisumio
Copy link

lisumio commented Aug 22, 2022

Assumption: Calling values method with null works by design and not by mistake (returns []).

R.values expects input obj to be a T generic that extends object , but this produces following error when passing nullable type:

Type 'null' is not assignable to type 'object'

PS. After checking ramda/ramda#3264 and seeing that #118 is left open I've decided to post this issue here rather than in DefinitelyTyped - hope it's alright.

@kpkonghk01
Copy link

kpkonghk01 commented Feb 10, 2024

Is it solved?

When I pass null into function values<T extends object>(obj: T): ValueOfUnion<T>[];, ValueOfUnion<null> becomes never. So values(null) returns type never[], which should be correct.

ref:
https://github.com/ramda/types/blob/develop/types/values.d.ts#L3C51-L3C63
https://github.com/ramda/types/blob/develop/types/util/tools.d.ts#L419

@kedashoe kedashoe transferred this issue from ramda/ramda Apr 7, 2024
@Harris-Miller
Copy link
Collaborator

R.values() rejects null same as Object.values. See here for example: https://tsplay.dev/WY5AxW

I believe the current implementation is correct. Closing

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

3 participants