Skip to content

[BUG] Incorrect/ambiguous docs for config.util.toObject() #890

@ChielBruin

Description

@ChielBruin

Describe the bug
The documentation for the config.util.toObject() states the following:

Returns a new deep copy of the current config object, or any part of the config if provided.

But looking at both the implementation and the type definition, this value must always be provided.

I would expect that this doc was never updated to reflect the changes to the internals of config.util in 4.2.0, as before that version this argument would indeed have been optional.

Expected behavior
I would either expect the documentation to not imply that the value is optional or for the implementation to support the old optionality of this argument.

Looking at the implementation it might also be the case that if you call it as config.util.toObject(config) in an attempt to get the old behaviour, the get/has/util/etc. fields will be included in the output. But maybe this was already the case with the old behaviour and I just never noticed.

Please tell us about your environment:

  • node-config version: 4.4.0 (upgrading from 4.1.0)
  • node-version: 24

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions