The Wayback Machine - https://web.archive.org/web/20240219144958/https://github.com/lodash/lodash/issues/4699
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

Please document that .get's object argument can be undefined or null #4699

Closed
jmm opened this issue Mar 18, 2020 · 2 comments
Closed

Please document that .get's object argument can be undefined or null #4699

jmm opened this issue Mar 18, 2020 · 2 comments
Labels
documentation issue bankruptcy Closing the issue/PR to start fresh

Comments

@jmm
Copy link

jmm commented Mar 18, 2020

So it's clear it's handled and won't throw and it's unnecessary to guard against it. In other words

object (Object|undefined|null)

I'd extend this to anything that behaves similarly -- like .pick, which actually coerces undefined or null to an object -- so you may as well consider in that context.

@jmm jmm changed the title Please document that .get's object argument can be == null Please document that .get's object argument can be undefined or null Mar 18, 2020
@bnjmnt4n
Copy link
Member

The issue with this is that lodash avoids erroring as far as possible, and most functions will account for cases where null and undefined are passed into them. Adding such warnings will add a lot of noise to the documentation, so I'm not sure if this is the right way to go.

@jmm
Copy link
Author

jmm commented Jan 20, 2021

Hi @bnjmnt4n, thanks for your reply.

I have to disagree that accurate documentation is noise.

On the other hand, a library being unwilling to document its behavior causes my code to be full of noise guarding against things like that. I have to treat it as an implementation detail, possibly even unintended, that what's documented as a non-optional Object argument can actually be undefined, null, or even omitted instead. I don't understand the logic of intentionally enabling that behavior, presumably so it's unnecessary to fill the calling code with noisy guards, and then not documenting it so it can be relied on.

You're comfortable pushing code to production that relies on undocumented behavior that could change in a patch release while complying with semver?

While I don't see an argument for not making the documentation accurate, there may be a way to avoid what you fear as noise. But I don't know what capabilities and constraints are involved in how you generate the documentation.

@jdalton jdalton added the issue bankruptcy Closing the issue/PR to start fresh label Sep 16, 2023
@jdalton jdalton closed this as completed Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation issue bankruptcy Closing the issue/PR to start fresh
Development

Successfully merging a pull request may close this issue.

3 participants