Skip to content

Commit

Permalink
fix(@angular-devkit/core): workspace reader spread/rest operator usag…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
alan-agius4 authored and kyliau committed Apr 21, 2020
1 parent 8baede8 commit 6ef9065
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ describe('readJsonWorkpace Parsing', () => {
);
});

it(`doesn't remove falsy values when using the spread operator`, async () => {
const host = createTestHost(representativeFile);
const workspace = await readJsonWorkspace('', host);
const prodConfig = workspace.projects.get('my-app')!.targets.get('build')!.configurations!.production!;
expect({ ...prodConfig }).toEqual(prodConfig);
});

it('parses extensions only into extensions object', async () => {
const host = createTestHost(representativeFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function create(
const propertyPath = path + '/' + escapeKey(p);
const cacheEntry = cache.get(propertyPath);
if (cacheEntry) {
if (cacheEntry.value) {
if (cacheEntry.value !== undefined) {
return createPropertyDescriptor(cacheEntry.value);
}

Expand Down

0 comments on commit 6ef9065

Please sign in to comment.