Skip to content

Commit

Permalink
Added a guard for missing property descriptor when inheriting enumerable
Browse files Browse the repository at this point in the history
  • Loading branch information
dr0p committed May 7, 2019
1 parent de7b0ec commit 1535f52
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/create-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ export class ViewModel<T> implements IViewModel<T> {
this.localComputedValues.set(key, computed(derivation.bind(this)))
}

const { enumerable } = Object.getOwnPropertyDescriptor(model, key)
const descriptor = Object.getOwnPropertyDescriptor(model, key);
const additionalDescriptor = descriptor ? { enumerable: descriptor.enumerable } : {};

Object.defineProperty(this, key, {
enumerable,
...additionalDescriptor,
configurable: true,
get: () => {
if (isComputedProp(model, key)) return this.localComputedValues.get(key).get()
Expand Down

0 comments on commit 1535f52

Please sign in to comment.