diff --git a/packages/workflow/src/AugmentObject.ts b/packages/workflow/src/AugmentObject.ts index dd4e868f85bcb..01e6f03ecb49d 100644 --- a/packages/workflow/src/AugmentObject.ts +++ b/packages/workflow/src/AugmentObject.ts @@ -33,7 +33,7 @@ export function augmentArray(data: T[]): T[] { return Reflect.deleteProperty(getData(), key); }, get(target, key: string, receiver): unknown { - const value = Reflect.get(newData !== undefined ? newData : target, key, receiver) as unknown; + const value = Reflect.get(newData ?? target, key, receiver) as unknown; const newValue = augment(value); if (newValue !== value) { newData = getData(); @@ -54,10 +54,10 @@ export function augmentArray(data: T[]): T[] { return Object.getOwnPropertyDescriptor(data, key) ?? defaultPropertyDescriptor; }, has(target, key) { - return Reflect.has(newData !== undefined ? newData : target, key); + return Reflect.has(newData ?? target, key); }, ownKeys(target) { - return Reflect.ownKeys(newData !== undefined ? newData : target); + return Reflect.ownKeys(newData ?? target); }, set(target, key: string, newValue: unknown) { // Always proxy all objects. Like that we can check in get simply if it @@ -134,8 +134,7 @@ export function augmentObject(data: T): T { }, has(target, key) { if (deletedProperties.indexOf(key) !== -1) return false; - const newKeys = Object.keys(newData); - return Reflect.has(newKeys.length ? newData : target, key); + return Reflect.has(newData, key) || Reflect.has(target, key); }, ownKeys(target) { const originalKeys = Reflect.ownKeys(target); diff --git a/packages/workflow/test/AugmentObject.test.ts b/packages/workflow/test/AugmentObject.test.ts index ab208f6c2189a..25cc6d4317b23 100644 --- a/packages/workflow/test/AugmentObject.test.ts +++ b/packages/workflow/test/AugmentObject.test.ts @@ -570,6 +570,7 @@ describe('AugmentObject', () => { augmentedObject.x.z = 5; expect('z' in augmentedObject.x).toBe(true); + expect('y' in augmentedObject.x).toBe(true); }); }); });