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

Lens props should not requires at least two argument #164

Open
steida opened this issue May 26, 2021 · 1 comment
Open

Lens props should not requires at least two argument #164

steida opened this issue May 26, 2021 · 1 comment

Comments

@steida
Copy link

steida commented May 26, 2021

I understand it's a helpful API, but in my general form library I have this code:

lens.props(...(Object.keys(action.values) as never)),

Which is correct I suppose, but I got Expected at least 2 arguments, but got 0 or more.

@kylegoetz
Copy link

kylegoetz commented Jul 5, 2021

The issue is that Object.keys does not guarantee it's returning a non-empty array. For example,

lens.props(...Object.keys({})) would be lens.props() which makes no sense.

Another issue is that Object.keys does not guarantee order. So you can't even be sure that your arguments are being passed in in the correct order.

One implementation of Object.keys({foo:'',bar:''}) might return ['foo','bar'] while another might return ['bar','foo']. So even if it works for you right now, there is no guarantee that it will continue to work, or will even work with another JavaScript implementation in another browser or a different version of Node, because the ECMA spec does not require Object.keys to return keys in any specific order.

So I'm not even sure you're right when you say your code is "correct."

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