Skip to content

Commit 6ef9065

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committedApr 21, 2020
fix(@angular-devkit/core): workspace reader spread/rest operator usage with falsy values
Spread and Rest uses `[[GetOwnProperty]]`. Previously, properties with falsy values were being removed when using the spread operator due to an incorrect check. https://tc39.es/proposal-object-rest-spread/#AbstractOperations-CopyDataProperties Fixes #17021
1 parent 8baede8 commit 6ef9065

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
 

‎packages/angular_devkit/core/src/workspace/json/reader_spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ describe('readJsonWorkpace Parsing', () => {
8686
);
8787
});
8888

89+
it(`doesn't remove falsy values when using the spread operator`, async () => {
90+
const host = createTestHost(representativeFile);
91+
const workspace = await readJsonWorkspace('', host);
92+
const prodConfig = workspace.projects.get('my-app')!.targets.get('build')!.configurations!.production!;
93+
expect({ ...prodConfig }).toEqual(prodConfig);
94+
});
95+
8996
it('parses extensions only into extensions object', async () => {
9097
const host = createTestHost(representativeFile);
9198

‎packages/angular_devkit/core/src/workspace/json/utilities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function create(
148148
const propertyPath = path + '/' + escapeKey(p);
149149
const cacheEntry = cache.get(propertyPath);
150150
if (cacheEntry) {
151-
if (cacheEntry.value) {
151+
if (cacheEntry.value !== undefined) {
152152
return createPropertyDescriptor(cacheEntry.value);
153153
}
154154

0 commit comments

Comments
 (0)
Please sign in to comment.