mobx-state-tree 5.0.1 → 5.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { isComputedProp, isObservableProp, createAtom, action, computed, _allowStateChangesInsideComputed, reaction, runInAction, observable, values, entries, _getGlobalState, isObservableArray, ObservableMap, _interceptReads, intercept, observe, _getAdministration, set, makeObservable, getAtom } from 'mobx';
1
+ import { isComputedProp, isObservableProp, createAtom, action, computed, _allowStateChangesInsideComputed, reaction, runInAction, observable, values, entries, _getGlobalState, isObservableArray, isObservableObject, defineProperty as defineProperty$1, ObservableMap, _interceptReads, intercept, observe, _getAdministration, set, makeObservable, getAtom } from 'mobx';
2
2
 
3
3
  var livelinessChecking = "warn";
4
4
  /**
@@ -64,11 +64,13 @@ PERFORMANCE OF THIS SOFTWARE.
64
64
  var extendStatics = function(d, b) {
65
65
  extendStatics = Object.setPrototypeOf ||
66
66
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
67
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
67
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
68
68
  return extendStatics(d, b);
69
69
  };
70
70
 
71
71
  function __extends(d, b) {
72
+ if (typeof b !== "function" && b !== null)
73
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
72
74
  extendStatics(d, b);
73
75
  function __() { this.constructor = d; }
74
76
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -154,6 +156,7 @@ function __read(o, n) {
154
156
  return ar;
155
157
  }
156
158
 
159
+ /** @deprecated */
157
160
  function __spread() {
158
161
  for (var ar = [], i = 0; i < arguments.length; i++)
159
162
  ar = ar.concat(__read(arguments[i]));
@@ -1123,6 +1126,14 @@ var BaseNode = /** @class */ (function () {
1123
1126
  enumerable: false,
1124
1127
  configurable: true
1125
1128
  });
1129
+ Object.defineProperty(BaseNode.prototype, "getReconciliationType", {
1130
+ enumerable: false,
1131
+ configurable: true,
1132
+ writable: true,
1133
+ value: function () {
1134
+ return this.type;
1135
+ }
1136
+ });
1126
1137
  Object.defineProperty(BaseNode.prototype, "baseSetParent", {
1127
1138
  enumerable: false,
1128
1139
  configurable: true,
@@ -2461,6 +2472,16 @@ var ComplexType = /** @class */ (function (_super) {
2461
2472
  return node.storedValue;
2462
2473
  }
2463
2474
  });
2475
+ Object.defineProperty(ComplexType.prototype, "isMatchingSnapshotId", {
2476
+ enumerable: false,
2477
+ configurable: true,
2478
+ writable: true,
2479
+ value: function (current, snapshot) {
2480
+ return (!current.identifierAttribute ||
2481
+ current.identifier ===
2482
+ normalizeIdentifier(snapshot[current.identifierAttribute]));
2483
+ }
2484
+ });
2464
2485
  Object.defineProperty(ComplexType.prototype, "tryToReconcileNode", {
2465
2486
  enumerable: false,
2466
2487
  configurable: true,
@@ -2479,9 +2500,7 @@ var ComplexType = /** @class */ (function (_super) {
2479
2500
  if (current.type === this &&
2480
2501
  isMutable(newValue) &&
2481
2502
  !isStateTreeNode(newValue) &&
2482
- (!current.identifierAttribute ||
2483
- current.identifier ===
2484
- normalizeIdentifier(newValue[current.identifierAttribute]))) {
2503
+ this.isMatchingSnapshotId(current, newValue)) {
2485
2504
  // the newValue has no node, so can be treated like a snapshot
2486
2505
  // we can reconcile
2487
2506
  current.applySnapshot(newValue);
@@ -3952,12 +3971,21 @@ function deepFreeze(value) {
3952
3971
  function isSerializable(value) {
3953
3972
  return typeof value !== "function";
3954
3973
  }
3974
+ /**
3975
+ * @internal
3976
+ * @hidden
3977
+ */
3978
+ function defineProperty(object, key, descriptor) {
3979
+ isObservableObject(object)
3980
+ ? defineProperty$1(object, key, descriptor)
3981
+ : Object.defineProperty(object, key, descriptor);
3982
+ }
3955
3983
  /**
3956
3984
  * @internal
3957
3985
  * @hidden
3958
3986
  */
3959
3987
  function addHiddenFinalProp(object, propName, value) {
3960
- Object.defineProperty(object, propName, {
3988
+ defineProperty(object, propName, {
3961
3989
  enumerable: false,
3962
3990
  writable: false,
3963
3991
  configurable: true,
@@ -3969,7 +3997,7 @@ function addHiddenFinalProp(object, propName, value) {
3969
3997
  * @hidden
3970
3998
  */
3971
3999
  function addHiddenWritableProp(object, propName, value) {
3972
- Object.defineProperty(object, propName, {
4000
+ defineProperty(object, propName, {
3973
4001
  enumerable: false,
3974
4002
  writable: true,
3975
4003
  configurable: true,
@@ -4562,6 +4590,8 @@ function splitJsonPath(path) {
4562
4590
  return parts;
4563
4591
  }
4564
4592
 
4593
+ /** @hidden */
4594
+ var $preProcessorFailed = Symbol("$preProcessorFailed");
4565
4595
  var SnapshotProcessor = /** @class */ (function (_super) {
4566
4596
  __extends(SnapshotProcessor, _super);
4567
4597
  function SnapshotProcessor(_subtype, _processors, name) {
@@ -4606,6 +4636,19 @@ var SnapshotProcessor = /** @class */ (function (_super) {
4606
4636
  return sn;
4607
4637
  }
4608
4638
  });
4639
+ Object.defineProperty(SnapshotProcessor.prototype, "preProcessSnapshotSafe", {
4640
+ enumerable: false,
4641
+ configurable: true,
4642
+ writable: true,
4643
+ value: function (sn) {
4644
+ try {
4645
+ return this.preProcessSnapshot(sn);
4646
+ }
4647
+ catch (e) {
4648
+ return $preProcessorFailed;
4649
+ }
4650
+ }
4651
+ });
4609
4652
  Object.defineProperty(SnapshotProcessor.prototype, "postProcessSnapshot", {
4610
4653
  enumerable: false,
4611
4654
  configurable: true,
@@ -4629,6 +4672,9 @@ var SnapshotProcessor = /** @class */ (function (_super) {
4629
4672
  node.getSnapshot = function () {
4630
4673
  return _this.postProcessSnapshot(oldGetSnapshot.call(node));
4631
4674
  };
4675
+ node.getReconciliationType = function () {
4676
+ return _this;
4677
+ };
4632
4678
  }
4633
4679
  });
4634
4680
  Object.defineProperty(SnapshotProcessor.prototype, "instantiate", {
@@ -4671,7 +4717,10 @@ var SnapshotProcessor = /** @class */ (function (_super) {
4671
4717
  configurable: true,
4672
4718
  writable: true,
4673
4719
  value: function (value, context) {
4674
- var processedSn = this.preProcessSnapshot(value);
4720
+ var processedSn = this.preProcessSnapshotSafe(value);
4721
+ if (processedSn === $preProcessorFailed) {
4722
+ return typeCheckFailure(context, value, "Failed to preprocess value");
4723
+ }
4675
4724
  return this._subtype.validate(processedSn, context);
4676
4725
  }
4677
4726
  });
@@ -4692,7 +4741,10 @@ var SnapshotProcessor = /** @class */ (function (_super) {
4692
4741
  ? this._subtype
4693
4742
  : isStateTreeNode(thing)
4694
4743
  ? getSnapshot(thing, false)
4695
- : this.preProcessSnapshot(thing);
4744
+ : this.preProcessSnapshotSafe(thing);
4745
+ if (value === $preProcessorFailed) {
4746
+ return false;
4747
+ }
4696
4748
  return this._subtype.validate(value, [{ path: "", type: this._subtype }]).length === 0;
4697
4749
  }
4698
4750
  });
@@ -4704,6 +4756,18 @@ var SnapshotProcessor = /** @class */ (function (_super) {
4704
4756
  return this._subtype.isAssignableFrom(type);
4705
4757
  }
4706
4758
  });
4759
+ Object.defineProperty(SnapshotProcessor.prototype, "isMatchingSnapshotId", {
4760
+ enumerable: false,
4761
+ configurable: true,
4762
+ writable: true,
4763
+ value: function (current, snapshot) {
4764
+ if (!(this._subtype instanceof ComplexType)) {
4765
+ return false;
4766
+ }
4767
+ var processedSn = this.preProcessSnapshot(snapshot);
4768
+ return this._subtype.isMatchingSnapshotId(current, processedSn);
4769
+ }
4770
+ });
4707
4771
  return SnapshotProcessor;
4708
4772
  }(BaseType));
4709
4773
  function proxyNodeTypeMethods(nodeType, snapshotProcessorType) {
@@ -5242,7 +5306,7 @@ MapType.prototype.applySnapshot = action(MapType.prototype.applySnapshot);
5242
5306
  * `types.map` - Creates a key based collection type who's children are all of a uniform declared type.
5243
5307
  * If the type stored in a map has an identifier, it is mandatory to store the child under that identifier in the map.
5244
5308
  *
5245
- * This type will always produce [observable maps](https://mobx.js.org/refguide/map.html)
5309
+ * This type will always produce [observable maps](https://mobx.js.org/api.html#observablemap)
5246
5310
  *
5247
5311
  * Example:
5248
5312
  * ```ts
@@ -5559,7 +5623,7 @@ ArrayType.prototype.applySnapshot = action(ArrayType.prototype.applySnapshot);
5559
5623
  /**
5560
5624
  * `types.array` - Creates an index based collection type who's children are all of a uniform declared type.
5561
5625
  *
5562
- * This type will always produce [observable arrays](https://mobx.js.org/refguide/array.html)
5626
+ * This type will always produce [observable arrays](https://mobx.js.org/api.html#observablearray)
5563
5627
  *
5564
5628
  * Example:
5565
5629
  * ```ts
@@ -5695,13 +5759,17 @@ function areSame(oldNode, newValue) {
5695
5759
  if (oldNode.snapshot === newValue) {
5696
5760
  return true;
5697
5761
  }
5762
+ // Non object nodes don't get reconciled
5763
+ if (!(oldNode instanceof ObjectNode)) {
5764
+ return false;
5765
+ }
5766
+ var oldNodeType = oldNode.getReconciliationType();
5698
5767
  // new value is a snapshot with the correct identifier
5699
- return (oldNode instanceof ObjectNode &&
5700
- oldNode.identifier !== null &&
5768
+ return (oldNode.identifier !== null &&
5701
5769
  oldNode.identifierAttribute &&
5702
5770
  isPlainObject(newValue) &&
5703
- oldNode.identifier === normalizeIdentifier(newValue[oldNode.identifierAttribute]) &&
5704
- oldNode.type.is(newValue));
5771
+ oldNodeType.is(newValue) &&
5772
+ oldNodeType.isMatchingSnapshotId(oldNode, newValue));
5705
5773
  }
5706
5774
  /**
5707
5775
  * Returns if a given value represents an array type.
@@ -6026,19 +6094,8 @@ var ModelType = /** @class */ (function (_super) {
6026
6094
  // is this a computed property?
6027
6095
  var descriptor = Object.getOwnPropertyDescriptor(views, key);
6028
6096
  if ("get" in descriptor) {
6029
- if (isComputedProp(self, key)) {
6030
- var computedValue = _getAdministration(self, key);
6031
- // TODO: mobx currently does not allow redefining computes yet, pending #1121
6032
- // FIXME: this binds to the internals of mobx!
6033
- computedValue.derivation = descriptor.get;
6034
- computedValue.scope = self;
6035
- if (descriptor.set)
6036
- computedValue.setter = action(computedValue.name + "-setter", descriptor.set);
6037
- }
6038
- else {
6039
- Object.defineProperty(self, key, descriptor);
6040
- makeObservable(self, (_a = {}, _a[key] = computed, _a));
6041
- }
6097
+ defineProperty$1(self, key, descriptor);
6098
+ makeObservable(self, (_a = {}, _a[key] = computed, _a));
6042
6099
  }
6043
6100
  else if (typeof descriptor.value === "function") {
6044
6101
  (!devMode() ? addHiddenFinalProp : addHiddenWritableProp)(self, key, descriptor.value);
@@ -6866,7 +6923,7 @@ var Union = /** @class */ (function (_super) {
6866
6923
  configurable: true,
6867
6924
  writable: true,
6868
6925
  value: function (current, newValue, parent, subpath) {
6869
- var type = this.determineType(newValue, current.type);
6926
+ var type = this.determineType(newValue, current.getReconciliationType());
6870
6927
  if (!type)
6871
6928
  throw fail$1("No matching type for union " + this.describe()); // can happen in prod builds
6872
6929
  return type.reconcile(current, newValue, parent, subpath);
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mobx')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'mobx'], factory) :
4
- (global = global || self, factory(global.mobxStateTree = {}, global.mobx));
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.mobxStateTree = {}, global.mobx));
5
5
  }(this, (function (exports, mobx) { 'use strict';
6
6
 
7
7
  var livelinessChecking = "warn";
@@ -68,11 +68,13 @@
68
68
  var extendStatics = function(d, b) {
69
69
  extendStatics = Object.setPrototypeOf ||
70
70
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
71
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
71
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
72
72
  return extendStatics(d, b);
73
73
  };
74
74
 
75
75
  function __extends(d, b) {
76
+ if (typeof b !== "function" && b !== null)
77
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
76
78
  extendStatics(d, b);
77
79
  function __() { this.constructor = d; }
78
80
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -158,6 +160,7 @@
158
160
  return ar;
159
161
  }
160
162
 
163
+ /** @deprecated */
161
164
  function __spread() {
162
165
  for (var ar = [], i = 0; i < arguments.length; i++)
163
166
  ar = ar.concat(__read(arguments[i]));
@@ -1127,6 +1130,14 @@
1127
1130
  enumerable: false,
1128
1131
  configurable: true
1129
1132
  });
1133
+ Object.defineProperty(BaseNode.prototype, "getReconciliationType", {
1134
+ enumerable: false,
1135
+ configurable: true,
1136
+ writable: true,
1137
+ value: function () {
1138
+ return this.type;
1139
+ }
1140
+ });
1130
1141
  Object.defineProperty(BaseNode.prototype, "baseSetParent", {
1131
1142
  enumerable: false,
1132
1143
  configurable: true,
@@ -2465,6 +2476,16 @@
2465
2476
  return node.storedValue;
2466
2477
  }
2467
2478
  });
2479
+ Object.defineProperty(ComplexType.prototype, "isMatchingSnapshotId", {
2480
+ enumerable: false,
2481
+ configurable: true,
2482
+ writable: true,
2483
+ value: function (current, snapshot) {
2484
+ return (!current.identifierAttribute ||
2485
+ current.identifier ===
2486
+ normalizeIdentifier(snapshot[current.identifierAttribute]));
2487
+ }
2488
+ });
2468
2489
  Object.defineProperty(ComplexType.prototype, "tryToReconcileNode", {
2469
2490
  enumerable: false,
2470
2491
  configurable: true,
@@ -2483,9 +2504,7 @@
2483
2504
  if (current.type === this &&
2484
2505
  isMutable(newValue) &&
2485
2506
  !isStateTreeNode(newValue) &&
2486
- (!current.identifierAttribute ||
2487
- current.identifier ===
2488
- normalizeIdentifier(newValue[current.identifierAttribute]))) {
2507
+ this.isMatchingSnapshotId(current, newValue)) {
2489
2508
  // the newValue has no node, so can be treated like a snapshot
2490
2509
  // we can reconcile
2491
2510
  current.applySnapshot(newValue);
@@ -3952,12 +3971,21 @@
3952
3971
  function isSerializable(value) {
3953
3972
  return typeof value !== "function";
3954
3973
  }
3974
+ /**
3975
+ * @internal
3976
+ * @hidden
3977
+ */
3978
+ function defineProperty(object, key, descriptor) {
3979
+ mobx.isObservableObject(object)
3980
+ ? mobx.defineProperty(object, key, descriptor)
3981
+ : Object.defineProperty(object, key, descriptor);
3982
+ }
3955
3983
  /**
3956
3984
  * @internal
3957
3985
  * @hidden
3958
3986
  */
3959
3987
  function addHiddenFinalProp(object, propName, value) {
3960
- Object.defineProperty(object, propName, {
3988
+ defineProperty(object, propName, {
3961
3989
  enumerable: false,
3962
3990
  writable: false,
3963
3991
  configurable: true,
@@ -3969,7 +3997,7 @@
3969
3997
  * @hidden
3970
3998
  */
3971
3999
  function addHiddenWritableProp(object, propName, value) {
3972
- Object.defineProperty(object, propName, {
4000
+ defineProperty(object, propName, {
3973
4001
  enumerable: false,
3974
4002
  writable: true,
3975
4003
  configurable: true,
@@ -4544,6 +4572,8 @@
4544
4572
  return parts;
4545
4573
  }
4546
4574
 
4575
+ /** @hidden */
4576
+ var $preProcessorFailed = Symbol("$preProcessorFailed");
4547
4577
  var SnapshotProcessor = /** @class */ (function (_super) {
4548
4578
  __extends(SnapshotProcessor, _super);
4549
4579
  function SnapshotProcessor(_subtype, _processors, name) {
@@ -4588,6 +4618,19 @@
4588
4618
  return sn;
4589
4619
  }
4590
4620
  });
4621
+ Object.defineProperty(SnapshotProcessor.prototype, "preProcessSnapshotSafe", {
4622
+ enumerable: false,
4623
+ configurable: true,
4624
+ writable: true,
4625
+ value: function (sn) {
4626
+ try {
4627
+ return this.preProcessSnapshot(sn);
4628
+ }
4629
+ catch (e) {
4630
+ return $preProcessorFailed;
4631
+ }
4632
+ }
4633
+ });
4591
4634
  Object.defineProperty(SnapshotProcessor.prototype, "postProcessSnapshot", {
4592
4635
  enumerable: false,
4593
4636
  configurable: true,
@@ -4611,6 +4654,9 @@
4611
4654
  node.getSnapshot = function () {
4612
4655
  return _this.postProcessSnapshot(oldGetSnapshot.call(node));
4613
4656
  };
4657
+ node.getReconciliationType = function () {
4658
+ return _this;
4659
+ };
4614
4660
  }
4615
4661
  });
4616
4662
  Object.defineProperty(SnapshotProcessor.prototype, "instantiate", {
@@ -4653,7 +4699,10 @@
4653
4699
  configurable: true,
4654
4700
  writable: true,
4655
4701
  value: function (value, context) {
4656
- var processedSn = this.preProcessSnapshot(value);
4702
+ var processedSn = this.preProcessSnapshotSafe(value);
4703
+ if (processedSn === $preProcessorFailed) {
4704
+ return typeCheckFailure(context, value, "Failed to preprocess value");
4705
+ }
4657
4706
  return this._subtype.validate(processedSn, context);
4658
4707
  }
4659
4708
  });
@@ -4674,7 +4723,10 @@
4674
4723
  ? this._subtype
4675
4724
  : isStateTreeNode(thing)
4676
4725
  ? getSnapshot(thing, false)
4677
- : this.preProcessSnapshot(thing);
4726
+ : this.preProcessSnapshotSafe(thing);
4727
+ if (value === $preProcessorFailed) {
4728
+ return false;
4729
+ }
4678
4730
  return this._subtype.validate(value, [{ path: "", type: this._subtype }]).length === 0;
4679
4731
  }
4680
4732
  });
@@ -4686,6 +4738,18 @@
4686
4738
  return this._subtype.isAssignableFrom(type);
4687
4739
  }
4688
4740
  });
4741
+ Object.defineProperty(SnapshotProcessor.prototype, "isMatchingSnapshotId", {
4742
+ enumerable: false,
4743
+ configurable: true,
4744
+ writable: true,
4745
+ value: function (current, snapshot) {
4746
+ if (!(this._subtype instanceof ComplexType)) {
4747
+ return false;
4748
+ }
4749
+ var processedSn = this.preProcessSnapshot(snapshot);
4750
+ return this._subtype.isMatchingSnapshotId(current, processedSn);
4751
+ }
4752
+ });
4689
4753
  return SnapshotProcessor;
4690
4754
  }(BaseType));
4691
4755
  function proxyNodeTypeMethods(nodeType, snapshotProcessorType) {
@@ -5000,7 +5064,7 @@
5000
5064
  Object.keys(hooks).forEach(function (name) {
5001
5065
  var hook = hooks[name];
5002
5066
  var actionInvoker = createActionInvoker(instance, name, hook);
5003
- ( addHiddenWritableProp)(instance, name, actionInvoker);
5067
+ (addHiddenWritableProp)(instance, name, actionInvoker);
5004
5068
  });
5005
5069
  });
5006
5070
  mobx.intercept(instance, this.willChange);
@@ -5224,7 +5288,7 @@
5224
5288
  * `types.map` - Creates a key based collection type who's children are all of a uniform declared type.
5225
5289
  * If the type stored in a map has an identifier, it is mandatory to store the child under that identifier in the map.
5226
5290
  *
5227
- * This type will always produce [observable maps](https://mobx.js.org/refguide/map.html)
5291
+ * This type will always produce [observable maps](https://mobx.js.org/api.html#observablemap)
5228
5292
  *
5229
5293
  * Example:
5230
5294
  * ```ts
@@ -5342,7 +5406,7 @@
5342
5406
  Object.keys(hooks).forEach(function (name) {
5343
5407
  var hook = hooks[name];
5344
5408
  var actionInvoker = createActionInvoker(instance, name, hook);
5345
- ( addHiddenWritableProp)(instance, name, actionInvoker);
5409
+ (addHiddenWritableProp)(instance, name, actionInvoker);
5346
5410
  });
5347
5411
  });
5348
5412
  mobx.intercept(instance, this.willChange);
@@ -5541,7 +5605,7 @@
5541
5605
  /**
5542
5606
  * `types.array` - Creates an index based collection type who's children are all of a uniform declared type.
5543
5607
  *
5544
- * This type will always produce [observable arrays](https://mobx.js.org/refguide/array.html)
5608
+ * This type will always produce [observable arrays](https://mobx.js.org/api.html#observablearray)
5545
5609
  *
5546
5610
  * Example:
5547
5611
  * ```ts
@@ -5677,13 +5741,17 @@
5677
5741
  if (oldNode.snapshot === newValue) {
5678
5742
  return true;
5679
5743
  }
5744
+ // Non object nodes don't get reconciled
5745
+ if (!(oldNode instanceof ObjectNode)) {
5746
+ return false;
5747
+ }
5748
+ var oldNodeType = oldNode.getReconciliationType();
5680
5749
  // new value is a snapshot with the correct identifier
5681
- return (oldNode instanceof ObjectNode &&
5682
- oldNode.identifier !== null &&
5750
+ return (oldNode.identifier !== null &&
5683
5751
  oldNode.identifierAttribute &&
5684
5752
  isPlainObject(newValue) &&
5685
- oldNode.identifier === normalizeIdentifier(newValue[oldNode.identifierAttribute]) &&
5686
- oldNode.type.is(newValue));
5753
+ oldNodeType.is(newValue) &&
5754
+ oldNodeType.isMatchingSnapshotId(oldNode, newValue));
5687
5755
  }
5688
5756
  /**
5689
5757
  * Returns if a given value represents an array type.
@@ -5742,11 +5810,11 @@
5742
5810
  return props;
5743
5811
  // its a function, maybe the user wanted a view?
5744
5812
  }
5745
- else if ( typeof value === "function") {
5813
+ else if (typeof value === "function") {
5746
5814
  throw fail$1("Invalid type definition for property '" + key + "', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?");
5747
5815
  // no other complex values
5748
5816
  }
5749
- else if ( typeof value === "object") {
5817
+ else if (typeof value === "object") {
5750
5818
  throw fail$1("Invalid type definition for property '" + key + "', it looks like you passed an object. Try passing another model type or a types.frozen.");
5751
5819
  // WTF did you pass in mate?
5752
5820
  }
@@ -5930,7 +5998,7 @@
5930
5998
  boundAction.$mst_middleware = middlewares;
5931
5999
  var actionInvoker = createActionInvoker(self, name, boundAction);
5932
6000
  actions[name] = actionInvoker;
5933
- ( addHiddenWritableProp)(self, name, actionInvoker);
6001
+ (addHiddenWritableProp)(self, name, actionInvoker);
5934
6002
  });
5935
6003
  }
5936
6004
  });
@@ -6008,22 +6076,11 @@
6008
6076
  // is this a computed property?
6009
6077
  var descriptor = Object.getOwnPropertyDescriptor(views, key);
6010
6078
  if ("get" in descriptor) {
6011
- if (mobx.isComputedProp(self, key)) {
6012
- var computedValue = mobx._getAdministration(self, key);
6013
- // TODO: mobx currently does not allow redefining computes yet, pending #1121
6014
- // FIXME: this binds to the internals of mobx!
6015
- computedValue.derivation = descriptor.get;
6016
- computedValue.scope = self;
6017
- if (descriptor.set)
6018
- computedValue.setter = mobx.action(computedValue.name + "-setter", descriptor.set);
6019
- }
6020
- else {
6021
- Object.defineProperty(self, key, descriptor);
6022
- mobx.makeObservable(self, (_a = {}, _a[key] = mobx.computed, _a));
6023
- }
6079
+ mobx.defineProperty(self, key, descriptor);
6080
+ mobx.makeObservable(self, (_a = {}, _a[key] = mobx.computed, _a));
6024
6081
  }
6025
6082
  else if (typeof descriptor.value === "function") {
6026
- ( addHiddenWritableProp)(self, key, descriptor.value);
6083
+ (addHiddenWritableProp)(self, key, descriptor.value);
6027
6084
  }
6028
6085
  else {
6029
6086
  throw fail$1("A view member should either be a function or getter based property");
@@ -6848,7 +6905,7 @@
6848
6905
  configurable: true,
6849
6906
  writable: true,
6850
6907
  value: function (current, newValue, parent, subpath) {
6851
- var type = this.determineType(newValue, current.type);
6908
+ var type = this.determineType(newValue, current.getReconciliationType());
6852
6909
  if (!type)
6853
6910
  throw fail$1("No matching type for union " + this.describe()); // can happen in prod builds
6854
6911
  return type.reconcile(current, newValue, parent, subpath);
@@ -7208,7 +7265,7 @@
7208
7265
  if (mustSucceed && t === undefined)
7209
7266
  throw fail$1("Late type seems to be used too early, the definition (still) returns undefined");
7210
7267
  if (t) {
7211
- if ( !isType(t))
7268
+ if (!isType(t))
7212
7269
  throw fail$1("Failed to determine subtype, make sure types.late returns a type definition.");
7213
7270
  this._subType = t;
7214
7271
  }