Is your feature request related to a problem? Please describe.
The existing config system had a subtle issue where Neo.mergeConfig method, responsible for merging default and instance config values, previously attempted shallow or deep merge operations even when the defaultValue or instanceValue were not objects. This could lead to semantically incorrect operations or potential runtime errors when dealing with primitive types, as object-specific merge logic is not applicable to non-object values.
Describe the solution you'd like
The Neo.mergeConfig method in src/Neo.mjs has been enhanced to ensure more robust type handling.
- It now explicitly checks the types of
defaultValue and instanceValue.
- The
shallow and deep merge strategies are now only applied if both defaultValue and instanceValue are objects.
- If either value is not an object, the method will fall back to the default 'replace' strategy, or apply a custom function strategy if one is provided.
This ensures that merge operations are semantically correct and prevents attempts to perform object-specific merges on non-object types.
Describe alternatives you've considered
The previous implementation was less strict about type checking, which led to the identified problem. The current solution directly addresses this by adding explicit type checks before applying object-specific merge logic. No other alternatives were considered as this is a direct refinement of the existing merge behavior.
Additional context
This enhancement improves the reliability and predictability of the config merging process within the Neo.mjs framework, ensuring that shallow and deep merges are only performed on appropriate data types.
Is your feature request related to a problem? Please describe. The existing config system had a subtle issue where
Neo.mergeConfigmethod, responsible for merging default and instance config values, previously attemptedshallowordeepmerge operations even when thedefaultValueorinstanceValuewere not objects. This could lead to semantically incorrect operations or potential runtime errors when dealing with primitive types, as object-specific merge logic is not applicable to non-object values.Describe the solution you'd like The
Neo.mergeConfigmethod insrc/Neo.mjshas been enhanced to ensure more robust type handling.defaultValueandinstanceValue.shallowanddeepmerge strategies are now only applied if bothdefaultValueandinstanceValueare objects.Describe alternatives you've considered The previous implementation was less strict about type checking, which led to the identified problem. The current solution directly addresses this by adding explicit type checks before applying object-specific merge logic. No other alternatives were considered as this is a direct refinement of the existing merge behavior.
Additional context This enhancement improves the reliability and predictability of the config merging process within the Neo.mjs framework, ensuring that
shallowanddeepmerges are only performed on appropriate data types.