-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api-extractor): Override lodash's array-merging behavior to make …
…config inheritance intelligible
- Loading branch information
Showing
7 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
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
27 changes: 27 additions & 0 deletions
27
apps/api-extractor/src/api/test/ExtractorConfig-merge.test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import * as path from 'path'; | ||
|
||
import { ExtractorConfig } from '../ExtractorConfig'; | ||
|
||
const testDataFolder: string = path.join(__dirname, 'test-data'); | ||
|
||
// Tests verifying the merge behavior of ExtractorConfig.loadFile | ||
describe(`${ExtractorConfig.name}.${ExtractorConfig.loadFile.name}`, () => { | ||
it('array properties completely override array properties in the base config', () => { | ||
const extractorConfig: ExtractorConfig = ExtractorConfig.loadFileAndPrepare( | ||
path.join(testDataFolder, 'override-array-properties/api-extractor.json') | ||
); | ||
// Base config specifies: ["alpha", "beta", "public"] | ||
// Derived config specifies: ["complete"] | ||
// By default, lodash's merge() function would generate ["complete", "beta", "public"], | ||
// but we instead want the derived config's array property to completely override that of the base. | ||
expect(extractorConfig.reportConfigs).toEqual([ | ||
{ | ||
variant: 'complete', | ||
fileName: 'override-array-properties.api.md' | ||
} | ||
]); | ||
}); | ||
}); |
2 changes: 2 additions & 0 deletions
2
apps/api-extractor/src/api/test/test-data/override-array-properties/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Reproduction of #4786. | ||
Merging of configs should *not* merge arrays - the overriding config file's array properties should completely overwrite the base config's array properties. |
18 changes: 18 additions & 0 deletions
18
apps/api-extractor/src/api/test/test-data/override-array-properties/api-extractor-base.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
|
||
"mainEntryPointFilePath": "index.d.ts", | ||
|
||
"apiReport": { | ||
"enabled": true, | ||
"reportVariants": ["alpha", "beta", "public"] | ||
}, | ||
|
||
"docModel": { | ||
"enabled": true | ||
}, | ||
|
||
"dtsRollup": { | ||
"enabled": true | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
apps/api-extractor/src/api/test/test-data/override-array-properties/api-extractor.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./api-extractor-base.json", | ||
|
||
"apiReport": { | ||
"reportVariants": ["complete"] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
apps/api-extractor/src/api/test/test-data/override-array-properties/index.d.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// empty file |
4 changes: 4 additions & 0 deletions
4
apps/api-extractor/src/api/test/test-data/override-array-properties/package.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "override-array-properties", | ||
"version": "1.0.0" | ||
} |