-
Notifications
You must be signed in to change notification settings - Fork 609
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
fix(api-extractor): More predictable merging of arrays in configuration #5071
Open
Josmithr
wants to merge
5
commits into
microsoft:main
Choose a base branch
from
Josmithr:josmithr/api-extractor/fix-config-inheritence
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(api-extractor): More predictable merging of arrays in configuration #5071
Josmithr
wants to merge
5
commits into
microsoft:main
from
Josmithr:josmithr/api-extractor/fix-config-inheritence
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…config inheritance intelligible
Josmithr
changed the title
fix(api-extractor): Override lodash's array-merging behavior to make config inheritance intelligible
fix(api-extractor): Update merge behavior for derived configurations to allow overriding array properties
Jan 9, 2025
Josmithr
commented
Jan 9, 2025
{ | ||
"packageName": "@microsoft/api-extractor", | ||
"comment": "Update merge behavior for derived configurations to allow overriding array properties", | ||
"type": "minor" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@octogonz per your suggestion, I made this a minor
-level change. This change is technically breaking, but the new behavior is much more predictable.
Josmithr
requested review from
iclanton,
octogonz,
apostolisms,
D4N14L and
dmichon-msft
as code owners
January 9, 2025 00:49
Josmithr
commented
Jan 9, 2025
Josmithr
changed the title
fix(api-extractor): Update merge behavior for derived configurations to allow overriding array properties
fix(api-extractor): More predictable merging of arrays in configuration
Jan 13, 2025
…://github.com/Josmithr/rushstack into josmithr/api-extractor/fix-config-inheritence
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for #4786
Merging of API-Extractor configurations leverages
Lodash
's merge functionality. For object / primitive properties, the resulting behavior is sensible. But for array properties, Lodash's merge behavior is very unintuitive.Consider a base API-Extractor configuration with the following properties:
And a derived configuration with the following properties:
What would you expect the merged configuration to look like? There are a couple of reasonable options here, but Lodash would yield:
Where each value is overridden on a by-index basis.
This is incredibly unintuitive behavior. Per the discussion in #4786, the merge logic has been updated such that array properties in derived configurations override array properties in base configurations. So for our example above, the merged configuration would look like:
Which is a predictable and intelligible behavior.
In the future, we may want to offer more user options for how to merge arrays, but in the short term this solution prevents confusing and error-prone behavior.