From 5462b7d652f488f2947d9626cb47bc9bd6d5c3ed Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 17 Dec 2019 01:09:23 -0500 Subject: [PATCH] Fixes log decorator on getters --- src/system/decorators/log.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/system/decorators/log.ts b/src/system/decorators/log.ts index ede17b8..bbf9e4e 100644 --- a/src/system/decorators/log.ts +++ b/src/system/decorators/log.ts @@ -86,18 +86,21 @@ export function log any>( | typeof Logger.debug | typeof Logger.log; - return (target: any, key: string, descriptor: PropertyDescriptor) => { + return (target: any, key: string, descriptor: PropertyDescriptor & { [key: string]: any }) => { let fn: Function | undefined; + let fnKey: string | undefined; if (typeof descriptor.value === 'function') { fn = descriptor.value; + fnKey = 'value'; } else if (typeof descriptor.get === 'function') { fn = descriptor.get; + fnKey = 'get'; } - if (fn == null) throw new Error('Not supported'); + if (fn == null || fnKey == null) throw new Error('Not supported'); const parameters = Functions.getParameters(fn); - descriptor.value = function(this: any, ...args: Parameters) { + descriptor[fnKey] = function(this: any, ...args: Parameters) { const correlationId = getNextCorrelationId(); if (