Take a look at my code snippet.
function observableDecorator<T>(target: T, key: keyof T) {
let observable = ko.observable<any>((target[key] as any));
Object.defineProperty(target, key, {
get() {
this[key]._ko_util_id = random;
this.obs = observable<
AT_THIS_POINT_THE_VALUE_TYPE_SHOULD_BE_INCLUDED
>();
},
set(value) {
observable(value);
}
});
}
I'm having trouble determining the type of value on line 6. I attempted to retrieve it from target[key]
, but it's returning undefined. Appreciate if someone can provide me with the correct solution. Will make sure to give credit to the helpful response.