mobx-state-tree 5.4.0 → 5.4.2-pre.1

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.
@@ -45,7 +45,7 @@ var Hook;
45
45
  Hook["beforeDestroy"] = "beforeDestroy";
46
46
  })(Hook || (Hook = {}));
47
47
 
48
- /*! *****************************************************************************
48
+ /******************************************************************************
49
49
  Copyright (c) Microsoft Corporation.
50
50
 
51
51
  Permission to use, copy, modify, and/or distribute this software for any
@@ -59,7 +59,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
59
59
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
60
60
  PERFORMANCE OF THIS SOFTWARE.
61
61
  ***************************************************************************** */
62
- /* global Reflect, Promise */
62
+ /* global Reflect, Promise, SuppressedError, Symbol */
63
63
 
64
64
  var extendStatics = function(d, b) {
65
65
  extendStatics = Object.setPrototypeOf ||
@@ -105,7 +105,7 @@ function __generator(thisArg, body) {
105
105
  function verb(n) { return function (v) { return step([n, v]); }; }
106
106
  function step(op) {
107
107
  if (f) throw new TypeError("Generator is already executing.");
108
- while (_) try {
108
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
109
109
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
110
110
  if (y = 0, t) op = [op[0] & 2, t.value];
111
111
  switch (op[0]) {
@@ -156,12 +156,20 @@ function __read(o, n) {
156
156
  return ar;
157
157
  }
158
158
 
159
- /** @deprecated */
160
- function __spread() {
161
- for (var ar = [], i = 0; i < arguments.length; i++)
162
- ar = ar.concat(__read(arguments[i]));
163
- return ar;
164
- }
159
+ function __spreadArray(to, from, pack) {
160
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
161
+ if (ar || !(i in from)) {
162
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
163
+ ar[i] = from[i];
164
+ }
165
+ }
166
+ return to.concat(ar || Array.prototype.slice.call(from));
167
+ }
168
+
169
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
170
+ var e = new Error(message);
171
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
172
+ };
165
173
 
166
174
  /**
167
175
  * Returns the _actual_ type of the given tree node. (Or throws)
@@ -344,7 +352,7 @@ function protect(target) {
344
352
  assertIsStateTreeNode(target, 1);
345
353
  var node = getStateTreeNode(target);
346
354
  if (!node.isRoot)
347
- throw fail$1("`protect` can only be invoked on root nodes");
355
+ throw fail("`protect` can only be invoked on root nodes");
348
356
  node.isProtectionEnabled = true;
349
357
  }
350
358
  /**
@@ -376,7 +384,7 @@ function unprotect(target) {
376
384
  assertIsStateTreeNode(target, 1);
377
385
  var node = getStateTreeNode(target);
378
386
  if (!node.isRoot)
379
- throw fail$1("`unprotect` can only be invoked on root nodes");
387
+ throw fail("`unprotect` can only be invoked on root nodes");
380
388
  node.isProtectionEnabled = false;
381
389
  }
382
390
  /**
@@ -459,7 +467,7 @@ function getParent(target, depth) {
459
467
  return parent.storedValue;
460
468
  parent = parent.parent;
461
469
  }
462
- throw fail$1("Failed to find the parent of " + getStateTreeNode(target) + " at depth " + depth);
470
+ throw fail("Failed to find the parent of ".concat(getStateTreeNode(target), " at depth ").concat(depth));
463
471
  }
464
472
  /**
465
473
  * Given a model instance, returns `true` if the object has a parent of given type, that is, is part of another object, map or array
@@ -497,7 +505,7 @@ function getParentOfType(target, type) {
497
505
  return parent.storedValue;
498
506
  parent = parent.parent;
499
507
  }
500
- throw fail$1("Failed to find the parent of " + getStateTreeNode(target) + " of a given type");
508
+ throw fail("Failed to find the parent of ".concat(getStateTreeNode(target), " of a given type"));
501
509
  }
502
510
  /**
503
511
  * Given an object in a model tree, returns the root object of that tree.
@@ -614,7 +622,7 @@ function tryReference(getter, checkIfAlive) {
614
622
  }
615
623
  }
616
624
  else {
617
- throw fail$1("The reference to be checked is not one of node, null or undefined");
625
+ throw fail("The reference to be checked is not one of node, null or undefined");
618
626
  }
619
627
  }
620
628
  catch (e) {
@@ -642,7 +650,7 @@ function isValidReference(getter, checkIfAlive) {
642
650
  return checkIfAlive ? isAlive(node) : true;
643
651
  }
644
652
  else {
645
- throw fail$1("The reference to be checked is not one of node, null or undefined");
653
+ throw fail("The reference to be checked is not one of node, null or undefined");
646
654
  }
647
655
  }
648
656
  catch (e) {
@@ -1297,7 +1305,7 @@ var ScalarNode = /** @class */ (function (_super) {
1297
1305
  get: function () {
1298
1306
  // future optimization: store root ref in the node and maintain it
1299
1307
  if (!this.parent)
1300
- throw fail$1("This scalar node is not part of a tree");
1308
+ throw fail("This scalar node is not part of a tree");
1301
1309
  return this.parent.root;
1302
1310
  },
1303
1311
  enumerable: false,
@@ -1316,15 +1324,15 @@ var ScalarNode = /** @class */ (function (_super) {
1316
1324
  if (devMode()) {
1317
1325
  if (!subpath) {
1318
1326
  // istanbul ignore next
1319
- throw fail$1("assertion failed: subpath expected");
1327
+ throw fail("assertion failed: subpath expected");
1320
1328
  }
1321
1329
  if (!newParent) {
1322
1330
  // istanbul ignore next
1323
- throw fail$1("assertion failed: parent expected");
1331
+ throw fail("assertion failed: parent expected");
1324
1332
  }
1325
1333
  if (parentChanged) {
1326
1334
  // istanbul ignore next
1327
- throw fail$1("assertion failed: scalar nodes cannot change their parent");
1335
+ throw fail("assertion failed: scalar nodes cannot change their parent");
1328
1336
  }
1329
1337
  }
1330
1338
  this.environment = undefined; // use parent's
@@ -1352,7 +1360,7 @@ var ScalarNode = /** @class */ (function (_super) {
1352
1360
  writable: true,
1353
1361
  value: function () {
1354
1362
  var path = (this.isAlive ? this.path : this.pathUponDeath) || "<root>";
1355
- return this.type.name + "@" + path + (this.isAlive ? "" : " [dead]");
1363
+ return "".concat(this.type.name, "@").concat(path).concat(this.isAlive ? "" : " [dead]");
1356
1364
  }
1357
1365
  });
1358
1366
  Object.defineProperty(ScalarNode.prototype, "die", {
@@ -1498,7 +1506,7 @@ var ObjectNode = /** @class */ (function (_super) {
1498
1506
  enumerable: true,
1499
1507
  configurable: true,
1500
1508
  writable: true,
1501
- value: 0 /* UNINITIALIZED */
1509
+ value: 0 /* ObservableInstanceLifecycle.UNINITIALIZED */
1502
1510
  });
1503
1511
  Object.defineProperty(_this, "_childNodes", {
1504
1512
  enumerable: true,
@@ -1565,7 +1573,7 @@ var ObjectNode = /** @class */ (function (_super) {
1565
1573
  }
1566
1574
  }
1567
1575
  if (typeof id !== "string" && typeof id !== "number") {
1568
- throw fail$1("Instance identifier '" + _this.identifierAttribute + "' for type '" + _this.type.name + "' must be a string or a number");
1576
+ throw fail("Instance identifier '".concat(_this.identifierAttribute, "' for type '").concat(_this.type.name, "' must be a string or a number"));
1569
1577
  }
1570
1578
  // normalize internal identifier to string
1571
1579
  _this.identifier = normalizeIdentifier(id);
@@ -1603,7 +1611,7 @@ var ObjectNode = /** @class */ (function (_super) {
1603
1611
  writable: true,
1604
1612
  value: function (fireHooks) {
1605
1613
  if (fireHooks === void 0) { fireHooks = true; }
1606
- if (this._observableInstanceState === 0 /* UNINITIALIZED */) {
1614
+ if (this._observableInstanceState === 0 /* ObservableInstanceLifecycle.UNINITIALIZED */) {
1607
1615
  this.createObservableInstance(fireHooks);
1608
1616
  }
1609
1617
  }
@@ -1618,10 +1626,10 @@ var ObjectNode = /** @class */ (function (_super) {
1618
1626
  if (devMode()) {
1619
1627
  if (this.state !== NodeLifeCycle.INITIALIZING) {
1620
1628
  // istanbul ignore next
1621
- throw fail$1("assertion failed: the creation of the observable instance must be done on the initializing phase");
1629
+ throw fail("assertion failed: the creation of the observable instance must be done on the initializing phase");
1622
1630
  }
1623
1631
  }
1624
- this._observableInstanceState = 1 /* CREATING */;
1632
+ this._observableInstanceState = 1 /* ObservableInstanceLifecycle.CREATING */;
1625
1633
  // make sure the parent chain is created as well
1626
1634
  // array with parent chain from parent to child
1627
1635
  var parentChain = [];
@@ -1631,7 +1639,7 @@ var ObjectNode = /** @class */ (function (_super) {
1631
1639
  // this is done to avoid traversing the whole tree to the root when using
1632
1640
  // the same reference again
1633
1641
  while (parent &&
1634
- parent._observableInstanceState === 0 /* UNINITIALIZED */) {
1642
+ parent._observableInstanceState === 0 /* ObservableInstanceLifecycle.UNINITIALIZED */) {
1635
1643
  parentChain.unshift(parent);
1636
1644
  parent = parent.parent;
1637
1645
  }
@@ -1665,7 +1673,7 @@ var ObjectNode = /** @class */ (function (_super) {
1665
1673
  finally {
1666
1674
  this._isRunningAction = false;
1667
1675
  }
1668
- this._observableInstanceState = 2 /* CREATED */;
1676
+ this._observableInstanceState = 2 /* ObservableInstanceLifecycle.CREATED */;
1669
1677
  this._snapshotComputed.trackAndCompute();
1670
1678
  if (this.isRoot)
1671
1679
  this._addSnapshotReaction();
@@ -1741,20 +1749,20 @@ var ObjectNode = /** @class */ (function (_super) {
1741
1749
  if (devMode()) {
1742
1750
  if (!subpath) {
1743
1751
  // istanbul ignore next
1744
- throw fail$1("assertion failed: subpath expected");
1752
+ throw fail("assertion failed: subpath expected");
1745
1753
  }
1746
1754
  if (!newParent) {
1747
1755
  // istanbul ignore next
1748
- throw fail$1("assertion failed: new parent expected");
1756
+ throw fail("assertion failed: new parent expected");
1749
1757
  }
1750
1758
  if (this.parent && parentChanged) {
1751
- throw fail$1("A node cannot exists twice in the state tree. Failed to add " + this + " to path '" + newParent.path + "/" + subpath + "'.");
1759
+ throw fail("A node cannot exists twice in the state tree. Failed to add ".concat(this, " to path '").concat(newParent.path, "/").concat(subpath, "'."));
1752
1760
  }
1753
1761
  if (!this.parent && newParent.root === this) {
1754
- throw fail$1("A state tree is not allowed to contain itself. Cannot assign " + this + " to path '" + newParent.path + "/" + subpath + "'");
1762
+ throw fail("A state tree is not allowed to contain itself. Cannot assign ".concat(this, " to path '").concat(newParent.path, "/").concat(subpath, "'"));
1755
1763
  }
1756
1764
  if (!this.parent && !!this.environment && this.environment !== newParent.root.environment) {
1757
- throw fail$1("A state tree cannot be made part of another state tree as long as their environments are different.");
1765
+ throw fail("A state tree cannot be made part of another state tree as long as their environments are different.");
1758
1766
  }
1759
1767
  }
1760
1768
  if (parentChanged) {
@@ -1810,7 +1818,7 @@ var ObjectNode = /** @class */ (function (_super) {
1810
1818
  value: function () {
1811
1819
  if (!this.isAlive)
1812
1820
  return this._snapshotUponDeath;
1813
- return this._observableInstanceState === 2 /* CREATED */
1821
+ return this._observableInstanceState === 2 /* ObservableInstanceLifecycle.CREATED */
1814
1822
  ? this._getActualSnapshot()
1815
1823
  : this._getCachedInitialSnapshot();
1816
1824
  }
@@ -1860,7 +1868,7 @@ var ObjectNode = /** @class */ (function (_super) {
1860
1868
  var error = this._getAssertAliveError(context);
1861
1869
  switch (livelinessChecking) {
1862
1870
  case "error":
1863
- throw fail$1(error);
1871
+ throw fail(error);
1864
1872
  case "warn":
1865
1873
  warnError(error);
1866
1874
  }
@@ -1883,9 +1891,9 @@ var ObjectNode = /** @class */ (function (_super) {
1883
1891
  if (actionContext && actionContext.name != null) {
1884
1892
  // try to use the context, and if it not available use the node one
1885
1893
  var actionPath = (actionContext && actionContext.context && getPath(actionContext.context)) || escapedPath;
1886
- actionFullPath = actionPath + "." + actionContext.name + "()";
1894
+ actionFullPath = "".concat(actionPath, ".").concat(actionContext.name, "()");
1887
1895
  }
1888
- return "You are trying to read or write to an object that is no longer part of a state tree. (Object type: '" + this.type.name + "', Path upon death: '" + escapedPath + "', Subpath: '" + subpath + "', Action: '" + actionFullPath + "'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.";
1896
+ return "You are trying to read or write to an object that is no longer part of a state tree. (Object type: '".concat(this.type.name, "', Path upon death: '").concat(escapedPath, "', Subpath: '").concat(subpath, "', Action: '").concat(actionFullPath, "'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.");
1889
1897
  }
1890
1898
  });
1891
1899
  Object.defineProperty(ObjectNode.prototype, "getChildNode", {
@@ -1898,7 +1906,7 @@ var ObjectNode = /** @class */ (function (_super) {
1898
1906
  });
1899
1907
  this._autoUnbox = false;
1900
1908
  try {
1901
- return this._observableInstanceState === 2 /* CREATED */
1909
+ return this._observableInstanceState === 2 /* ObservableInstanceLifecycle.CREATED */
1902
1910
  ? this.type.getChildNode(this, subpath)
1903
1911
  : this._childNodes[subpath];
1904
1912
  }
@@ -1915,7 +1923,7 @@ var ObjectNode = /** @class */ (function (_super) {
1915
1923
  this.assertAlive(EMPTY_OBJECT);
1916
1924
  this._autoUnbox = false;
1917
1925
  try {
1918
- return this._observableInstanceState === 2 /* CREATED */
1926
+ return this._observableInstanceState === 2 /* ObservableInstanceLifecycle.CREATED */
1919
1927
  ? this.type.getChildren(this)
1920
1928
  : convertChildNodesToArray(this._childNodes);
1921
1929
  }
@@ -1946,7 +1954,7 @@ var ObjectNode = /** @class */ (function (_super) {
1946
1954
  value: function (context) {
1947
1955
  this.assertAlive(context);
1948
1956
  if (!this.isRunningAction() && this.isProtected) {
1949
- throw fail$1("Cannot modify '" + this + "', the object is protected and can only be modified by using an action.");
1957
+ throw fail("Cannot modify '".concat(this, "', the object is protected and can only be modified by using an action."));
1950
1958
  }
1951
1959
  }
1952
1960
  });
@@ -1978,8 +1986,8 @@ var ObjectNode = /** @class */ (function (_super) {
1978
1986
  writable: true,
1979
1987
  value: function () {
1980
1988
  var path = (this.isAlive ? this.path : this.pathUponDeath) || "<root>";
1981
- var identifier = this.identifier ? "(id: " + this.identifier + ")" : "";
1982
- return this.type.name + "@" + path + identifier + (this.isAlive ? "" : " [dead]");
1989
+ var identifier = this.identifier ? "(id: ".concat(this.identifier, ")") : "";
1990
+ return "".concat(this.type.name, "@").concat(path).concat(identifier).concat(this.isAlive ? "" : " [dead]");
1983
1991
  }
1984
1992
  });
1985
1993
  Object.defineProperty(ObjectNode.prototype, "finalizeCreation", {
@@ -2013,7 +2021,7 @@ var ObjectNode = /** @class */ (function (_super) {
2013
2021
  writable: true,
2014
2022
  value: function () {
2015
2023
  if (!this.isAlive)
2016
- throw fail$1("Error while detaching, node is not alive.");
2024
+ throw fail("Error while detaching, node is not alive.");
2017
2025
  this.clearParent();
2018
2026
  }
2019
2027
  });
@@ -2061,7 +2069,7 @@ var ObjectNode = /** @class */ (function (_super) {
2061
2069
  configurable: true,
2062
2070
  writable: true,
2063
2071
  value: function () {
2064
- if (this._observableInstanceState === 0 /* UNINITIALIZED */) {
2072
+ if (this._observableInstanceState === 0 /* ObservableInstanceLifecycle.UNINITIALIZED */) {
2065
2073
  return;
2066
2074
  }
2067
2075
  this.getChildren().forEach(function (node) {
@@ -2070,8 +2078,8 @@ var ObjectNode = /** @class */ (function (_super) {
2070
2078
  // beforeDestroy should run before the disposers since else we could end up in a situation where
2071
2079
  // a disposer added with addDisposer at this stage (beforeDestroy) is actually never released
2072
2080
  this.baseAboutToDie();
2073
- this._internalEventsEmit("dispose" /* Dispose */);
2074
- this._internalEventsClear("dispose" /* Dispose */);
2081
+ this._internalEventsEmit("dispose" /* InternalEvents.Dispose */);
2082
+ this._internalEventsClear("dispose" /* InternalEvents.Dispose */);
2075
2083
  }
2076
2084
  });
2077
2085
  Object.defineProperty(ObjectNode.prototype, "finalizeDeath", {
@@ -2097,7 +2105,7 @@ var ObjectNode = /** @class */ (function (_super) {
2097
2105
  writable: true,
2098
2106
  value: function (onChange) {
2099
2107
  this._addSnapshotReaction();
2100
- return this._internalEventsRegister("snapshot" /* Snapshot */, onChange);
2108
+ return this._internalEventsRegister("snapshot" /* InternalEvents.Snapshot */, onChange);
2101
2109
  }
2102
2110
  });
2103
2111
  Object.defineProperty(ObjectNode.prototype, "emitSnapshot", {
@@ -2105,7 +2113,7 @@ var ObjectNode = /** @class */ (function (_super) {
2105
2113
  configurable: true,
2106
2114
  writable: true,
2107
2115
  value: function (snapshot) {
2108
- this._internalEventsEmit("snapshot" /* Snapshot */, snapshot);
2116
+ this._internalEventsEmit("snapshot" /* InternalEvents.Snapshot */, snapshot);
2109
2117
  }
2110
2118
  });
2111
2119
  Object.defineProperty(ObjectNode.prototype, "onPatch", {
@@ -2113,7 +2121,7 @@ var ObjectNode = /** @class */ (function (_super) {
2113
2121
  configurable: true,
2114
2122
  writable: true,
2115
2123
  value: function (handler) {
2116
- return this._internalEventsRegister("patch" /* Patch */, handler);
2124
+ return this._internalEventsRegister("patch" /* InternalEvents.Patch */, handler);
2117
2125
  }
2118
2126
  });
2119
2127
  Object.defineProperty(ObjectNode.prototype, "emitPatch", {
@@ -2121,12 +2129,12 @@ var ObjectNode = /** @class */ (function (_super) {
2121
2129
  configurable: true,
2122
2130
  writable: true,
2123
2131
  value: function (basePatch, source) {
2124
- if (this._internalEventsHasSubscribers("patch" /* Patch */)) {
2132
+ if (this._internalEventsHasSubscribers("patch" /* InternalEvents.Patch */)) {
2125
2133
  var localizedPatch = extend({}, basePatch, {
2126
2134
  path: source.path.substr(this.path.length) + "/" + basePatch.path // calculate the relative path of the patch
2127
2135
  });
2128
2136
  var _a = __read(splitPatch(localizedPatch), 2), patch = _a[0], reversePatch = _a[1];
2129
- this._internalEventsEmit("patch" /* Patch */, patch, reversePatch);
2137
+ this._internalEventsEmit("patch" /* InternalEvents.Patch */, patch, reversePatch);
2130
2138
  }
2131
2139
  if (this.parent)
2132
2140
  this.parent.emitPatch(basePatch, source);
@@ -2137,7 +2145,7 @@ var ObjectNode = /** @class */ (function (_super) {
2137
2145
  configurable: true,
2138
2146
  writable: true,
2139
2147
  value: function (disposer) {
2140
- return this._internalEventsHas("dispose" /* Dispose */, disposer);
2148
+ return this._internalEventsHas("dispose" /* InternalEvents.Dispose */, disposer);
2141
2149
  }
2142
2150
  });
2143
2151
  Object.defineProperty(ObjectNode.prototype, "addDisposer", {
@@ -2146,10 +2154,10 @@ var ObjectNode = /** @class */ (function (_super) {
2146
2154
  writable: true,
2147
2155
  value: function (disposer) {
2148
2156
  if (!this.hasDisposer(disposer)) {
2149
- this._internalEventsRegister("dispose" /* Dispose */, disposer, true);
2157
+ this._internalEventsRegister("dispose" /* InternalEvents.Dispose */, disposer, true);
2150
2158
  return;
2151
2159
  }
2152
- throw fail$1("cannot add a disposer when it is already registered for execution");
2160
+ throw fail("cannot add a disposer when it is already registered for execution");
2153
2161
  }
2154
2162
  });
2155
2163
  Object.defineProperty(ObjectNode.prototype, "removeDisposer", {
@@ -2157,10 +2165,10 @@ var ObjectNode = /** @class */ (function (_super) {
2157
2165
  configurable: true,
2158
2166
  writable: true,
2159
2167
  value: function (disposer) {
2160
- if (!this._internalEventsHas("dispose" /* Dispose */, disposer)) {
2161
- throw fail$1("cannot remove a disposer which was never registered for execution");
2168
+ if (!this._internalEventsHas("dispose" /* InternalEvents.Dispose */, disposer)) {
2169
+ throw fail("cannot remove a disposer which was never registered for execution");
2162
2170
  }
2163
- this._internalEventsUnregister("dispose" /* Dispose */, disposer);
2171
+ this._internalEventsUnregister("dispose" /* InternalEvents.Dispose */, disposer);
2164
2172
  }
2165
2173
  });
2166
2174
  Object.defineProperty(ObjectNode.prototype, "removeMiddleware", {
@@ -2268,7 +2276,7 @@ var ObjectNode = /** @class */ (function (_super) {
2268
2276
  args[_i - 1] = arguments[_i];
2269
2277
  }
2270
2278
  if (this._internalEvents) {
2271
- (_a = this._internalEvents).emit.apply(_a, __spread([event], args));
2279
+ (_a = this._internalEvents).emit.apply(_a, __spreadArray([event], __read(args), false));
2272
2280
  }
2273
2281
  }
2274
2282
  });
@@ -2404,7 +2412,7 @@ var BaseType = /** @class */ (function () {
2404
2412
  writable: true,
2405
2413
  value: function (node, applyPostProcess) {
2406
2414
  // istanbul ignore next
2407
- throw fail$1("unimplemented method");
2415
+ throw fail("unimplemented method");
2408
2416
  }
2409
2417
  });
2410
2418
  Object.defineProperty(BaseType.prototype, "isAssignableFrom", {
@@ -2442,7 +2450,7 @@ var BaseType = /** @class */ (function () {
2442
2450
  Object.defineProperty(BaseType.prototype, "Type", {
2443
2451
  get: function () {
2444
2452
  // istanbul ignore next
2445
- throw fail$1("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`");
2453
+ throw fail("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`");
2446
2454
  },
2447
2455
  enumerable: false,
2448
2456
  configurable: true
@@ -2450,7 +2458,7 @@ var BaseType = /** @class */ (function () {
2450
2458
  Object.defineProperty(BaseType.prototype, "TypeWithoutSTN", {
2451
2459
  get: function () {
2452
2460
  // istanbul ignore next
2453
- throw fail$1("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`");
2461
+ throw fail("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`");
2454
2462
  },
2455
2463
  enumerable: false,
2456
2464
  configurable: true
@@ -2458,7 +2466,7 @@ var BaseType = /** @class */ (function () {
2458
2466
  Object.defineProperty(BaseType.prototype, "SnapshotType", {
2459
2467
  get: function () {
2460
2468
  // istanbul ignore next
2461
- throw fail$1("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`");
2469
+ throw fail("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`");
2462
2470
  },
2463
2471
  enumerable: false,
2464
2472
  configurable: true
@@ -2466,7 +2474,7 @@ var BaseType = /** @class */ (function () {
2466
2474
  Object.defineProperty(BaseType.prototype, "CreationType", {
2467
2475
  get: function () {
2468
2476
  // istanbul ignore next
2469
- throw fail$1("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`");
2477
+ throw fail("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`");
2470
2478
  },
2471
2479
  enumerable: false,
2472
2480
  configurable: true
@@ -2911,11 +2919,11 @@ function serializeArgument(node, actionName, index, arg) {
2911
2919
  // We should not serialize MST nodes, even if we can, because we don't know if the receiving party can handle a raw snapshot instead of an
2912
2920
  // MST type instance. So if one wants to serialize a MST node that was pass in, either explitly pass: 1: an id, 2: a (relative) path, 3: a snapshot
2913
2921
  if (isStateTreeNode(arg))
2914
- return serializeTheUnserializable("[MSTNode: " + getType(arg).name + "]");
2922
+ return serializeTheUnserializable("[MSTNode: ".concat(getType(arg).name, "]"));
2915
2923
  if (typeof arg === "function")
2916
2924
  return serializeTheUnserializable("[function]");
2917
2925
  if (typeof arg === "object" && !isPlainObject(arg) && !isArray(arg))
2918
- return serializeTheUnserializable("[object " + ((arg && arg.constructor && arg.constructor.name) || "Complex Object") + "]");
2926
+ return serializeTheUnserializable("[object ".concat((arg && arg.constructor && arg.constructor.name) || "Complex Object", "]"));
2919
2927
  try {
2920
2928
  // Check if serializable, cycle free etc...
2921
2929
  // MWE: there must be a better way....
@@ -2956,7 +2964,7 @@ function applyAction(target, actions) {
2956
2964
  function baseApplyAction(target, action) {
2957
2965
  var resolvedTarget = tryResolve(target, action.path || "");
2958
2966
  if (!resolvedTarget)
2959
- throw fail$1("Invalid action path: " + (action.path || ""));
2967
+ throw fail("Invalid action path: ".concat(action.path || ""));
2960
2968
  var node = getStateTreeNode(resolvedTarget);
2961
2969
  // Reserved functions
2962
2970
  if (action.name === "@APPLY_PATCHES") {
@@ -2966,7 +2974,7 @@ function baseApplyAction(target, action) {
2966
2974
  return applySnapshot.call(null, resolvedTarget, action.args[0]);
2967
2975
  }
2968
2976
  if (!(typeof resolvedTarget[action.name] === "function"))
2969
- throw fail$1("Action '" + action.name + "' does not exist in '" + node.path + "'");
2977
+ throw fail("Action '".concat(action.name, "' does not exist in '").concat(node.path, "'"));
2970
2978
  return resolvedTarget[action.name].apply(resolvedTarget, action.args ? action.args.map(function (v) { return deserializeArgument(node, v); }) : []);
2971
2979
  }
2972
2980
  /**
@@ -3171,7 +3179,7 @@ function createActionInvoker(target, name, fn) {
3171
3179
  tree: getRoot(target),
3172
3180
  rootId: parentContext ? parentContext.rootId : id,
3173
3181
  parentId: parentContext ? parentContext.id : 0,
3174
- allParentIds: parentContext ? __spread(parentContext.allParentIds, [parentContext.id]) : [],
3182
+ allParentIds: parentContext ? __spreadArray(__spreadArray([], __read(parentContext.allParentIds), false), [parentContext.id], false) : [],
3175
3183
  parentEvent: parentContext,
3176
3184
  parentActionEvent: parentActionContext
3177
3185
  }, fn);
@@ -3327,11 +3335,11 @@ function runMiddleWares(node, baseCall, originalFn) {
3327
3335
  if (devMode()) {
3328
3336
  if (!nextInvoked && !abortInvoked) {
3329
3337
  var node2 = getStateTreeNode(call.tree);
3330
- throw fail$1("Neither the next() nor the abort() callback within the middleware " + handler.name + " for the action: \"" + call.name + "\" on the node: " + node2.type.name + " was invoked.");
3338
+ throw fail("Neither the next() nor the abort() callback within the middleware ".concat(handler.name, " for the action: \"").concat(call.name, "\" on the node: ").concat(node2.type.name, " was invoked."));
3331
3339
  }
3332
3340
  else if (nextInvoked && abortInvoked) {
3333
3341
  var node2 = getStateTreeNode(call.tree);
3334
- throw fail$1("The next() and abort() callback within the middleware " + handler.name + " for the action: \"" + call.name + "\" on the node: " + node2.type.name + " were invoked.");
3342
+ throw fail("The next() and abort() callback within the middleware ".concat(handler.name, " for the action: \"").concat(call.name, "\" on the node: ").concat(node2.type.name, " were invoked."));
3335
3343
  }
3336
3344
  }
3337
3345
  return result;
@@ -3381,7 +3389,7 @@ function safeStringify(value) {
3381
3389
  }
3382
3390
  catch (e) {
3383
3391
  // istanbul ignore next
3384
- return "<Unserializable: " + e + ">";
3392
+ return "<Unserializable: ".concat(e, ">");
3385
3393
  }
3386
3394
  }
3387
3395
  /**
@@ -3390,15 +3398,15 @@ function safeStringify(value) {
3390
3398
  */
3391
3399
  function prettyPrintValue(value) {
3392
3400
  return typeof value === "function"
3393
- ? "<function" + (value.name ? " " + value.name : "") + ">"
3401
+ ? "<function".concat(value.name ? " " + value.name : "", ">")
3394
3402
  : isStateTreeNode(value)
3395
- ? "<" + value + ">"
3396
- : "`" + safeStringify(value) + "`";
3403
+ ? "<".concat(value, ">")
3404
+ : "`".concat(safeStringify(value), "`");
3397
3405
  }
3398
3406
  function shortenPrintValue(valueInString) {
3399
3407
  return valueInString.length < 280
3400
3408
  ? valueInString
3401
- : valueInString.substring(0, 272) + "......" + valueInString.substring(valueInString.length - 8);
3409
+ : "".concat(valueInString.substring(0, 272), "......").concat(valueInString.substring(valueInString.length - 8));
3402
3410
  }
3403
3411
  function toErrorString(error) {
3404
3412
  var value = error.value;
@@ -3410,19 +3418,19 @@ function toErrorString(error) {
3410
3418
  })
3411
3419
  .filter(function (path) { return path.length > 0; })
3412
3420
  .join("/");
3413
- var pathPrefix = fullPath.length > 0 ? "at path \"/" + fullPath + "\" " : "";
3421
+ var pathPrefix = fullPath.length > 0 ? "at path \"/".concat(fullPath, "\" ") : "";
3414
3422
  var currentTypename = isStateTreeNode(value)
3415
- ? "value of type " + getStateTreeNode(value).type.name + ":"
3423
+ ? "value of type ".concat(getStateTreeNode(value).type.name, ":")
3416
3424
  : isPrimitive(value)
3417
3425
  ? "value"
3418
3426
  : "snapshot";
3419
3427
  var isSnapshotCompatible = type && isStateTreeNode(value) && type.is(getStateTreeNode(value).snapshot);
3420
- return ("" + pathPrefix + currentTypename + " " + prettyPrintValue(value) + " is not assignable " + (type ? "to type: `" + type.name + "`" : "") +
3421
- (error.message ? " (" + error.message + ")" : "") +
3428
+ return ("".concat(pathPrefix).concat(currentTypename, " ").concat(prettyPrintValue(value), " is not assignable ").concat(type ? "to type: `".concat(type.name, "`") : "") +
3429
+ (error.message ? " (".concat(error.message, ")") : "") +
3422
3430
  (type
3423
3431
  ? isPrimitiveType(type) || isPrimitive(value)
3424
3432
  ? "."
3425
- : ", expected an instance of `" + type.name + "` or a snapshot like `" + type.describe() + "` instead." +
3433
+ : ", expected an instance of `".concat(type.name, "` or a snapshot like `").concat(type.describe(), "` instead.") +
3426
3434
  (isSnapshotCompatible
3427
3435
  ? " (Note that a snapshot of the provided value is compatible with the targeted type)"
3428
3436
  : "")
@@ -3478,14 +3486,14 @@ function typecheckInternal(type, value) {
3478
3486
  function typecheck(type, value) {
3479
3487
  var errors = type.validate(value, [{ path: "", type: type }]);
3480
3488
  if (errors.length > 0) {
3481
- throw fail$1(validationErrorsToString(type, value, errors));
3489
+ throw fail(validationErrorsToString(type, value, errors));
3482
3490
  }
3483
3491
  }
3484
3492
  function validationErrorsToString(type, value, errors) {
3485
3493
  if (errors.length === 0) {
3486
3494
  return undefined;
3487
3495
  }
3488
- return ("Error while converting " + shortenPrintValue(prettyPrintValue(value)) + " to `" + type.name + "`:\n\n " + errors.map(toErrorString).join("\n "));
3496
+ return ("Error while converting ".concat(shortenPrintValue(prettyPrintValue(value)), " to `").concat(type.name, "`:\n\n ") + errors.map(toErrorString).join("\n "));
3489
3497
  }
3490
3498
 
3491
3499
  var identifierCacheId = 0;
@@ -3533,7 +3541,7 @@ var IdentifierCache = /** @class */ (function () {
3533
3541
  writable: true,
3534
3542
  value: function (identifier) {
3535
3543
  var modificationId = this.lastCacheModificationPerId.get(identifier) || 0;
3536
- return this.cacheId + "-" + modificationId;
3544
+ return "".concat(this.cacheId, "-").concat(modificationId);
3537
3545
  }
3538
3546
  });
3539
3547
  Object.defineProperty(IdentifierCache.prototype, "addNodeToCache", {
@@ -3549,7 +3557,7 @@ var IdentifierCache = /** @class */ (function () {
3549
3557
  }
3550
3558
  var set = this.cache.get(identifier);
3551
3559
  if (set.indexOf(node) !== -1)
3552
- throw fail$1("Already registered");
3560
+ throw fail("Already registered");
3553
3561
  set.push(node);
3554
3562
  if (lastCacheUpdate) {
3555
3563
  this.updateLastCacheModificationPerId(identifier);
@@ -3648,9 +3656,9 @@ var IdentifierCache = /** @class */ (function () {
3648
3656
  case 1:
3649
3657
  return matches[0];
3650
3658
  default:
3651
- throw fail$1("Cannot resolve a reference to type '" + type.name + "' with id: '" + identifier + "' unambigously, there are multiple candidates: " + matches
3659
+ throw fail("Cannot resolve a reference to type '".concat(type.name, "' with id: '").concat(identifier, "' unambigously, there are multiple candidates: ").concat(matches
3652
3660
  .map(function (n) { return n.path; })
3653
- .join(", "));
3661
+ .join(", ")));
3654
3662
  }
3655
3663
  }
3656
3664
  });
@@ -3666,7 +3674,7 @@ function createObjectNode(type, parent, subpath, environment, initialValue) {
3666
3674
  if (existingNode) {
3667
3675
  if (existingNode.parent) {
3668
3676
  // istanbul ignore next
3669
- throw fail$1("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '" + (parent ? parent.path : "") + "/" + subpath + "', but it lives already at '" + existingNode.path + "'");
3677
+ throw fail("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(parent ? parent.path : "", "/").concat(subpath, "', but it lives already at '").concat(existingNode.path, "'"));
3670
3678
  }
3671
3679
  if (parent) {
3672
3680
  existingNode.setParent(parent, subpath);
@@ -3729,7 +3737,7 @@ function assertIsStateTreeNode(value, argNumber) {
3729
3737
  function getStateTreeNode(value) {
3730
3738
  if (!isStateTreeNode(value)) {
3731
3739
  // istanbul ignore next
3732
- throw fail$1("Value " + value + " is no MST Node");
3740
+ throw fail("Value ".concat(value, " is no MST Node"));
3733
3741
  }
3734
3742
  return value.$treenode;
3735
3743
  }
@@ -3755,7 +3763,7 @@ var doubleDot = function (_) { return ".."; };
3755
3763
  function getRelativePathBetweenNodes(base, target) {
3756
3764
  // PRE condition target is (a child of) base!
3757
3765
  if (base.root !== target.root) {
3758
- throw fail$1("Cannot calculate relative path: objects '" + base + "' and '" + target + "' are not part of the same object tree");
3766
+ throw fail("Cannot calculate relative path: objects '".concat(base, "' and '").concat(target, "' are not part of the same object tree"));
3759
3767
  }
3760
3768
  var baseParts = splitJsonPath(base.path);
3761
3769
  var targetParts = splitJsonPath(target.path);
@@ -3812,7 +3820,7 @@ function resolveNodeByPathParts(base, pathParts, failIfResolveFails) {
3812
3820
  }
3813
3821
  }
3814
3822
  }
3815
- throw fail$1("Could not resolve '" + part + "' in path '" + (joinJsonPath(pathParts.slice(0, i)) || "/") + "' while resolving '" + joinJsonPath(pathParts) + "'");
3823
+ throw fail("Could not resolve '".concat(part, "' in path '").concat(joinJsonPath(pathParts.slice(0, i)) || "/", "' while resolving '").concat(joinJsonPath(pathParts), "'"));
3816
3824
  }
3817
3825
  }
3818
3826
  catch (e) {
@@ -3888,7 +3896,7 @@ Object.freeze(mobxShallow);
3888
3896
  * @internal
3889
3897
  * @hidden
3890
3898
  */
3891
- function fail$1(message) {
3899
+ function fail(message) {
3892
3900
  if (message === void 0) { message = "Illegal state"; }
3893
3901
  return new Error("[mobx-state-tree] " + message);
3894
3902
  }
@@ -4132,7 +4140,7 @@ var EventHandler = /** @class */ (function () {
4132
4140
  }
4133
4141
  // make a copy just in case it changes
4134
4142
  var handlers = this.handlers.slice();
4135
- handlers.forEach(function (f) { return f.apply(void 0, __spread(args)); });
4143
+ handlers.forEach(function (f) { return f.apply(void 0, __spreadArray([], __read(args), false)); });
4136
4144
  }
4137
4145
  });
4138
4146
  return EventHandler;
@@ -4225,7 +4233,7 @@ var EventHandlers = /** @class */ (function () {
4225
4233
  }
4226
4234
  var handler = this.eventHandlers && this.eventHandlers[event];
4227
4235
  if (handler) {
4228
- (_a = handler).emit.apply(_a, __spread(args));
4236
+ (_a = handler).emit.apply(_a, __spreadArray([], __read(args), false));
4229
4237
  }
4230
4238
  }
4231
4239
  });
@@ -4270,7 +4278,7 @@ deprecated.ids = {};
4270
4278
  * @hidden
4271
4279
  */
4272
4280
  function warnError(msg) {
4273
- console.warn(new Error("[mobx-state-tree] " + msg));
4281
+ console.warn(new Error("[mobx-state-tree] ".concat(msg)));
4274
4282
  }
4275
4283
  /**
4276
4284
  * @internal
@@ -4295,7 +4303,7 @@ function assertArg(value, fn, typeName, argNumber) {
4295
4303
  if (devMode()) {
4296
4304
  if (!fn(value)) {
4297
4305
  // istanbul ignore next
4298
- throw fail$1("expected " + typeName + " as argument " + asArray(argNumber).join(" or ") + ", got " + value + " instead");
4306
+ throw fail("expected ".concat(typeName, " as argument ").concat(asArray(argNumber).join(" or "), ", got ").concat(value, " instead"));
4299
4307
  }
4300
4308
  }
4301
4309
  }
@@ -4313,10 +4321,10 @@ function assertIsFunction(value, argNumber) {
4313
4321
  function assertIsNumber(value, argNumber, min, max) {
4314
4322
  assertArg(value, function (n) { return typeof n === "number"; }, "number", argNumber);
4315
4323
  if (min !== undefined) {
4316
- assertArg(value, function (n) { return n >= min; }, "number greater than " + min, argNumber);
4324
+ assertArg(value, function (n) { return n >= min; }, "number greater than ".concat(min), argNumber);
4317
4325
  }
4318
4326
  if (max !== undefined) {
4319
- assertArg(value, function (n) { return n <= max; }, "number lesser than " + max, argNumber);
4327
+ assertArg(value, function (n) { return n <= max; }, "number lesser than ".concat(max), argNumber);
4320
4328
  }
4321
4329
  }
4322
4330
  /**
@@ -4395,7 +4403,7 @@ function toGeneratorFunction(p) {
4395
4403
  }
4396
4404
  return __generator(this, function (_a) {
4397
4405
  switch (_a.label) {
4398
- case 0: return [4 /*yield*/, p.apply(void 0, __spread(args))];
4406
+ case 0: return [4 /*yield*/, p.apply(void 0, __spreadArray([], __read(args), false))];
4399
4407
  case 1: return [2 /*return*/, (_a.sent())];
4400
4408
  }
4401
4409
  });
@@ -4440,11 +4448,11 @@ function createFlowSpawner(name, generator) {
4440
4448
  var runId = getNextActionId();
4441
4449
  var parentContext = getCurrentActionContext();
4442
4450
  if (!parentContext) {
4443
- throw fail$1("a mst flow must always have a parent context");
4451
+ throw fail("a mst flow must always have a parent context");
4444
4452
  }
4445
4453
  var parentActionContext = getParentActionContext(parentContext);
4446
4454
  if (!parentActionContext) {
4447
- throw fail$1("a mst flow must always have a parent action context");
4455
+ throw fail("a mst flow must always have a parent action context");
4448
4456
  }
4449
4457
  var contextBase = {
4450
4458
  name: name,
@@ -4452,7 +4460,7 @@ function createFlowSpawner(name, generator) {
4452
4460
  tree: parentContext.tree,
4453
4461
  context: parentContext.context,
4454
4462
  parentId: parentContext.id,
4455
- allParentIds: __spread(parentContext.allParentIds, [parentContext.id]),
4463
+ allParentIds: __spreadArray(__spreadArray([], __read(parentContext.allParentIds), false), [parentContext.id], false),
4456
4464
  rootId: parentContext.rootId,
4457
4465
  parentEvent: parentContext,
4458
4466
  parentActionEvent: parentActionContext
@@ -4515,7 +4523,7 @@ function createFlowSpawner(name, generator) {
4515
4523
  // TODO: support more type of values? See https://github.com/tj/co/blob/249bbdc72da24ae44076afd716349d2089b31c4c/index.js#L100
4516
4524
  if (!ret.value || typeof ret.value.then !== "function") {
4517
4525
  // istanbul ignore next
4518
- throw fail$1("Only promises can be yielded to `async`, got: " + ret);
4526
+ throw fail("Only promises can be yielded to `async`, got: " + ret);
4519
4527
  }
4520
4528
  return ret.value.then(onFulfilled, onRejected);
4521
4529
  }
@@ -4531,7 +4539,7 @@ function createFlowSpawner(name, generator) {
4531
4539
  */
4532
4540
  function splitPatch(patch) {
4533
4541
  if (!("oldValue" in patch))
4534
- throw fail$1("Patches without `oldValue` field cannot be inversed");
4542
+ throw fail("Patches without `oldValue` field cannot be inversed");
4535
4543
  return [stripPatch(patch), invertPatch(patch)];
4536
4544
  }
4537
4545
  /**
@@ -4632,7 +4640,7 @@ function splitJsonPath(path) {
4632
4640
  stringStartsWith(path, "./") ||
4633
4641
  stringStartsWith(path, "../");
4634
4642
  if (!valid) {
4635
- throw fail$1("a json path must be either rooted, empty or relative, but got '" + path + "'");
4643
+ throw fail("a json path must be either rooted, empty or relative, but got '".concat(path, "'"));
4636
4644
  }
4637
4645
  // '/a/b/c' -> ["a", "b", "c"]
4638
4646
  // '../../b/c' -> ["..", "..", "b", "c"]
@@ -4678,7 +4686,7 @@ var SnapshotProcessor = /** @class */ (function (_super) {
4678
4686
  configurable: true,
4679
4687
  writable: true,
4680
4688
  value: function () {
4681
- return "snapshotProcessor(" + this._subtype.describe() + ")";
4689
+ return "snapshotProcessor(".concat(this._subtype.describe(), ")");
4682
4690
  }
4683
4691
  });
4684
4692
  Object.defineProperty(SnapshotProcessor.prototype, "preProcessSnapshot", {
@@ -4980,28 +4988,28 @@ var MSTMap = /** @class */ (function (_super) {
4980
4988
  writable: true,
4981
4989
  value: function (value) {
4982
4990
  if (!value)
4983
- throw fail$1("Map.put cannot be used to set empty values");
4991
+ throw fail("Map.put cannot be used to set empty values");
4984
4992
  if (isStateTreeNode(value)) {
4985
4993
  var node = getStateTreeNode(value);
4986
4994
  if (devMode()) {
4987
4995
  if (!node.identifierAttribute) {
4988
- throw fail$1(needsIdentifierError);
4996
+ throw fail(needsIdentifierError);
4989
4997
  }
4990
4998
  }
4991
4999
  if (node.identifier === null) {
4992
- throw fail$1(needsIdentifierError);
5000
+ throw fail(needsIdentifierError);
4993
5001
  }
4994
5002
  this.set(node.identifier, value);
4995
5003
  return value;
4996
5004
  }
4997
5005
  else if (!isMutable(value)) {
4998
- throw fail$1("Map.put can only be used to store complex values");
5006
+ throw fail("Map.put can only be used to store complex values");
4999
5007
  }
5000
5008
  else {
5001
5009
  var mapNode = getStateTreeNode(this);
5002
5010
  var mapType = mapNode.type;
5003
5011
  if (mapType.identifierMode !== MapIdentifierMode.YES) {
5004
- throw fail$1(needsIdentifierError);
5012
+ throw fail(needsIdentifierError);
5005
5013
  }
5006
5014
  var idAttr = mapType.mapIdentifierAttribute;
5007
5015
  var id = value[idAttr];
@@ -5094,7 +5102,7 @@ var MapType = /** @class */ (function (_super) {
5094
5102
  if (!type.identifierAttribute)
5095
5103
  return current;
5096
5104
  if (current && current !== type.identifierAttribute) {
5097
- throw fail$1("The objects in a map should all have the same identifier attribute, expected '" + current + "', but child of type '" + type.name + "' declared attribute '" + type.identifierAttribute + "' as identifier");
5105
+ throw fail("The objects in a map should all have the same identifier attribute, expected '".concat(current, "', but child of type '").concat(type.name, "' declared attribute '").concat(type.identifierAttribute, "' as identifier"));
5098
5106
  }
5099
5107
  return type.identifierAttribute;
5100
5108
  }, undefined);
@@ -5173,7 +5181,7 @@ var MapType = /** @class */ (function (_super) {
5173
5181
  value: function (node, key) {
5174
5182
  var childNode = node.storedValue.get("" + key);
5175
5183
  if (!childNode)
5176
- throw fail$1("Not a child " + key);
5184
+ throw fail("Not a child " + key);
5177
5185
  return childNode;
5178
5186
  }
5179
5187
  });
@@ -5218,7 +5226,7 @@ var MapType = /** @class */ (function (_super) {
5218
5226
  if (this.identifierMode === MapIdentifierMode.YES && node instanceof ObjectNode) {
5219
5227
  var identifier = node.identifier;
5220
5228
  if (identifier !== expected)
5221
- throw fail$1("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '" + identifier + "', but expected: '" + expected + "'");
5229
+ throw fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '".concat(identifier, "', but expected: '").concat(expected, "'"));
5222
5230
  }
5223
5231
  }
5224
5232
  });
@@ -5390,7 +5398,7 @@ MapType.prototype.applySnapshot = action(MapType.prototype.applySnapshot);
5390
5398
  * @returns
5391
5399
  */
5392
5400
  function map(subtype) {
5393
- return new MapType("Map<string, " + subtype.name + ">", subtype);
5401
+ return new MapType("Map<string, ".concat(subtype.name, ">"), subtype);
5394
5402
  }
5395
5403
  /**
5396
5404
  * Returns if a given value represents a map type.
@@ -5516,7 +5524,7 @@ var ArrayType = /** @class */ (function (_super) {
5516
5524
  var index = Number(key);
5517
5525
  if (index < node.storedValue.length)
5518
5526
  return node.storedValue[index];
5519
- throw fail$1("Not a child: " + key);
5527
+ throw fail("Not a child: " + key);
5520
5528
  }
5521
5529
  });
5522
5530
  Object.defineProperty(ArrayType.prototype, "willChange", {
@@ -5707,7 +5715,7 @@ ArrayType.prototype.applySnapshot = action(ArrayType.prototype.applySnapshot);
5707
5715
  */
5708
5716
  function array(subtype) {
5709
5717
  assertIsType(subtype, 1);
5710
- return new ArrayType(subtype.name + "[]", subtype);
5718
+ return new ArrayType("".concat(subtype.name, "[]"), subtype);
5711
5719
  }
5712
5720
  function reconcileArrayChildren(parent, childType, oldNodes, newValues, newPaths) {
5713
5721
  var nothingChanged = true;
@@ -5741,7 +5749,7 @@ function reconcileArrayChildren(parent, childType, oldNodes, newValues, newPaths
5741
5749
  // check if already belongs to the same parent. if so, avoid pushing item in. only swapping can occur.
5742
5750
  if (isStateTreeNode(newValue) && getStateTreeNode(newValue).parent === parent) {
5743
5751
  // this node is owned by this parent, but not in the reconcilable set, so it must be double
5744
- throw fail$1("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '" + parent.path + "/" + newPath + "', but it lives already at '" + getStateTreeNode(newValue).path + "'");
5752
+ throw fail("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(parent.path, "/").concat(newPath, "', but it lives already at '").concat(getStateTreeNode(newValue).path, "'"));
5745
5753
  }
5746
5754
  nothingChanged = false;
5747
5755
  var newNode = valueAsNode(childType, parent, newPath, newValue);
@@ -5857,7 +5865,7 @@ function toPropertiesObject(declaredProps) {
5857
5865
  var alreadySeenKeys = new Set();
5858
5866
  keysList.forEach(function (key) {
5859
5867
  if (alreadySeenKeys.has(key)) {
5860
- throw fail$1(key + " is declared twice in the model. Model should not contain the same keys");
5868
+ throw fail("".concat(key, " is declared twice in the model. Model should not contain the same keys"));
5861
5869
  }
5862
5870
  alreadySeenKeys.add(key);
5863
5871
  });
@@ -5865,17 +5873,17 @@ function toPropertiesObject(declaredProps) {
5865
5873
  return keysList.reduce(function (props, key) {
5866
5874
  // warn if user intended a HOOK
5867
5875
  if (key in Hook) {
5868
- throw fail$1("Hook '" + key + "' was defined as property. Hooks should be defined as part of the actions");
5876
+ throw fail("Hook '".concat(key, "' was defined as property. Hooks should be defined as part of the actions"));
5869
5877
  }
5870
5878
  // the user intended to use a view
5871
5879
  var descriptor = Object.getOwnPropertyDescriptor(declaredProps, key);
5872
5880
  if ("get" in descriptor) {
5873
- throw fail$1("Getters are not supported as properties. Please use views instead");
5881
+ throw fail("Getters are not supported as properties. Please use views instead");
5874
5882
  }
5875
5883
  // undefined and null are not valid
5876
5884
  var value = descriptor.value;
5877
5885
  if (value === null || value === undefined) {
5878
- throw fail$1("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");
5886
+ throw fail("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");
5879
5887
  }
5880
5888
  // its a primitive, convert to its type
5881
5889
  else if (isPrimitive(value)) {
@@ -5892,14 +5900,14 @@ function toPropertiesObject(declaredProps) {
5892
5900
  else if (isType(value)) ;
5893
5901
  // its a function, maybe the user wanted a view?
5894
5902
  else if (devMode() && typeof value === "function") {
5895
- 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?");
5903
+ throw fail("Invalid type definition for property '".concat(key, "', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?"));
5896
5904
  }
5897
5905
  // no other complex values
5898
5906
  else if (devMode() && typeof value === "object") {
5899
- 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.");
5907
+ throw fail("Invalid type definition for property '".concat(key, "', it looks like you passed an object. Try passing another model type or a types.frozen."));
5900
5908
  }
5901
5909
  else {
5902
- throw fail$1("Invalid type definition for property '" + key + "', cannot infer a type from a value like '" + value + "' (" + typeof value + ")");
5910
+ throw fail("Invalid type definition for property '".concat(key, "', cannot infer a type from a value like '").concat(value, "' (").concat(typeof value, ")"));
5903
5911
  }
5904
5912
  return props;
5905
5913
  }, declaredProps);
@@ -6012,7 +6020,7 @@ var ModelType = /** @class */ (function (_super) {
6012
6020
  this.forAllProps(function (propName, propType) {
6013
6021
  if (propType.flags & TypeFlags.Identifier) {
6014
6022
  if (identifierAttribute)
6015
- throw fail$1("Cannot define property '" + propName + "' as object identifier, property '" + identifierAttribute + "' is already defined as identifier property");
6023
+ throw fail("Cannot define property '".concat(propName, "' as object identifier, property '").concat(identifierAttribute, "' is already defined as identifier property"));
6016
6024
  identifierAttribute = propName;
6017
6025
  }
6018
6026
  });
@@ -6053,15 +6061,15 @@ var ModelType = /** @class */ (function (_super) {
6053
6061
  value: function (self, actions) {
6054
6062
  // check if return is correct
6055
6063
  if (!isPlainObject(actions))
6056
- throw fail$1("actions initializer should return a plain object containing actions");
6064
+ throw fail("actions initializer should return a plain object containing actions");
6057
6065
  // bind actions to the object created
6058
6066
  Object.keys(actions).forEach(function (name) {
6059
6067
  // warn if preprocessor was given
6060
6068
  if (name === PRE_PROCESS_SNAPSHOT)
6061
- throw fail$1("Cannot define action '" + PRE_PROCESS_SNAPSHOT + "', it should be defined using 'type.preProcessSnapshot(fn)' instead");
6069
+ throw fail("Cannot define action '".concat(PRE_PROCESS_SNAPSHOT, "', it should be defined using 'type.preProcessSnapshot(fn)' instead"));
6062
6070
  // warn if postprocessor was given
6063
6071
  if (name === POST_PROCESS_SNAPSHOT)
6064
- throw fail$1("Cannot define action '" + POST_PROCESS_SNAPSHOT + "', it should be defined using 'type.postProcessSnapshot(fn)' instead");
6072
+ throw fail("Cannot define action '".concat(POST_PROCESS_SNAPSHOT, "', it should be defined using 'type.postProcessSnapshot(fn)' instead"));
6065
6073
  var action2 = actions[name];
6066
6074
  // apply hook composition
6067
6075
  var baseAction = self[name];
@@ -6091,7 +6099,7 @@ var ModelType = /** @class */ (function (_super) {
6091
6099
  value: function (fn) {
6092
6100
  var _this = this;
6093
6101
  if (typeof fn !== "function") {
6094
- throw fail$1("You passed an " + typeof fn + " to volatile state as an argument, when function is expected");
6102
+ throw fail("You passed an ".concat(typeof fn, " to volatile state as an argument, when function is expected"));
6095
6103
  }
6096
6104
  var stateInitializer = function (self) {
6097
6105
  _this.instantiateVolatileState(self, fn(self));
@@ -6107,7 +6115,7 @@ var ModelType = /** @class */ (function (_super) {
6107
6115
  value: function (self, state) {
6108
6116
  // check views return
6109
6117
  if (!isPlainObject(state))
6110
- throw fail$1("volatile state initializer should return a plain object containing state");
6118
+ throw fail("volatile state initializer should return a plain object containing state");
6111
6119
  set(self, state);
6112
6120
  }
6113
6121
  });
@@ -6120,7 +6128,7 @@ var ModelType = /** @class */ (function (_super) {
6120
6128
  var initializer = function (self) {
6121
6129
  var _a = fn(self), actions = _a.actions, views = _a.views, state = _a.state, rest = __rest(_a, ["actions", "views", "state"]);
6122
6130
  for (var key in rest)
6123
- throw fail$1("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '" + key + "'");
6131
+ throw fail("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(key, "'"));
6124
6132
  if (state)
6125
6133
  _this.instantiateVolatileState(self, state);
6126
6134
  if (views)
@@ -6152,7 +6160,7 @@ var ModelType = /** @class */ (function (_super) {
6152
6160
  value: function (self, views) {
6153
6161
  // check views return
6154
6162
  if (!isPlainObject(views))
6155
- throw fail$1("views initializer should return a plain object containing views");
6163
+ throw fail("views initializer should return a plain object containing views");
6156
6164
  Object.getOwnPropertyNames(views).forEach(function (key) {
6157
6165
  var _a;
6158
6166
  // is this a computed property?
@@ -6165,7 +6173,7 @@ var ModelType = /** @class */ (function (_super) {
6165
6173
  (!devMode() ? addHiddenFinalProp : addHiddenWritableProp)(self, key, descriptor.value);
6166
6174
  }
6167
6175
  else {
6168
- throw fail$1("A view member should either be a function or getter based property");
6176
+ throw fail("A view member should either be a function or getter based property");
6169
6177
  }
6170
6178
  });
6171
6179
  }
@@ -6281,11 +6289,11 @@ var ModelType = /** @class */ (function (_super) {
6281
6289
  value: function (node, key) {
6282
6290
  var _a;
6283
6291
  if (!(key in this.properties))
6284
- throw fail$1("Not a value property: " + key);
6292
+ throw fail("Not a value property: " + key);
6285
6293
  var adm = _getAdministration(node.storedValue, key);
6286
6294
  var childNode = (_a = adm.raw) === null || _a === void 0 ? void 0 : _a.call(adm);
6287
6295
  if (!childNode)
6288
- throw fail$1("Node not available for property " + key);
6296
+ throw fail("Node not available for property " + key);
6289
6297
  return childNode;
6290
6298
  }
6291
6299
  });
@@ -6304,7 +6312,7 @@ var ModelType = /** @class */ (function (_super) {
6304
6312
  atom.reportObserved();
6305
6313
  }
6306
6314
  catch (e) {
6307
- throw fail$1(name + " property is declared twice");
6315
+ throw fail("".concat(name, " property is declared twice"));
6308
6316
  }
6309
6317
  res[name] = _this.getChildNode(node, name).snapshot;
6310
6318
  });
@@ -6332,7 +6340,7 @@ var ModelType = /** @class */ (function (_super) {
6332
6340
  writable: true,
6333
6341
  value: function (node, subpath, patch) {
6334
6342
  if (!(patch.op === "replace" || patch.op === "add")) {
6335
- throw fail$1("object does not support operation " + patch.op);
6343
+ throw fail("object does not support operation ".concat(patch.op));
6336
6344
  }
6337
6345
  node.storedValue[subpath] = patch.value;
6338
6346
  }
@@ -6444,7 +6452,7 @@ function model() {
6444
6452
  args[_i] = arguments[_i];
6445
6453
  }
6446
6454
  if (devMode() && typeof args[0] !== "string" && args[1]) {
6447
- throw fail$1("Model creation failed. First argument must be a string when two arguments are provided");
6455
+ throw fail("Model creation failed. First argument must be a string when two arguments are provided");
6448
6456
  }
6449
6457
  var name = typeof args[0] === "string" ? args.shift() : "AnonymousModel";
6450
6458
  var properties = args.shift() || {};
@@ -6564,7 +6572,7 @@ var CoreType = /** @class */ (function (_super) {
6564
6572
  return typeCheckSuccess();
6565
6573
  }
6566
6574
  var typeName = this.name === "Date" ? "Date or a unix milliseconds timestamp" : this.name;
6567
- return typeCheckFailure(context, value, "Value is not a " + typeName);
6575
+ return typeCheckFailure(context, value, "Value is not a ".concat(typeName));
6568
6576
  }
6569
6577
  });
6570
6578
  return CoreType;
@@ -6691,7 +6699,7 @@ function getPrimitiveFactoryFromValue(value) {
6691
6699
  if (value instanceof Date)
6692
6700
  return DatePrimitive;
6693
6701
  }
6694
- throw fail$1("Cannot determine primitive type from value " + value);
6702
+ throw fail("Cannot determine primitive type from value " + value);
6695
6703
  }
6696
6704
  /**
6697
6705
  * Returns if a given value represents a primitive type.
@@ -6757,7 +6765,7 @@ var Literal = /** @class */ (function (_super) {
6757
6765
  if (isPrimitive(value) && value === this.value) {
6758
6766
  return typeCheckSuccess();
6759
6767
  }
6760
- return typeCheckFailure(context, value, "Value is not a literal " + JSON.stringify(this.value));
6768
+ return typeCheckFailure(context, value, "Value is not a literal ".concat(JSON.stringify(this.value)));
6761
6769
  }
6762
6770
  });
6763
6771
  return Literal;
@@ -6939,7 +6947,7 @@ function enumeration(name, options) {
6939
6947
  assertIsString(option, i + 1);
6940
6948
  });
6941
6949
  }
6942
- var type = union.apply(void 0, __spread(realOptions.map(function (option) { return literal("" + option); })));
6950
+ var type = union.apply(void 0, __spreadArray([], __read(realOptions.map(function (option) { return literal("" + option); })), false));
6943
6951
  if (typeof name === "string")
6944
6952
  type.name = name;
6945
6953
  return type;
@@ -7011,7 +7019,7 @@ var Union = /** @class */ (function (_super) {
7011
7019
  value: function (parent, subpath, environment, initialValue) {
7012
7020
  var type = this.determineType(initialValue, undefined);
7013
7021
  if (!type)
7014
- throw fail$1("No matching type for union " + this.describe()); // can happen in prod builds
7022
+ throw fail("No matching type for union " + this.describe()); // can happen in prod builds
7015
7023
  return type.instantiate(parent, subpath, environment, initialValue);
7016
7024
  }
7017
7025
  });
@@ -7022,7 +7030,7 @@ var Union = /** @class */ (function (_super) {
7022
7030
  value: function (current, newValue, parent, subpath) {
7023
7031
  var type = this.determineType(newValue, current.getReconciliationType());
7024
7032
  if (!type)
7025
- throw fail$1("No matching type for union " + this.describe()); // can happen in prod builds
7033
+ throw fail("No matching type for union " + this.describe()); // can happen in prod builds
7026
7034
  return type.reconcile(current, newValue, parent, subpath);
7027
7035
  }
7028
7036
  });
@@ -7035,7 +7043,7 @@ var Union = /** @class */ (function (_super) {
7035
7043
  if (this._dispatcher) {
7036
7044
  return this._dispatcher(value);
7037
7045
  }
7038
- // find the most accomodating type
7046
+ // find the most accommodating type
7039
7047
  // if we are using reconciliation try the current node type first (fix for #1045)
7040
7048
  if (reconcileCurrentType) {
7041
7049
  if (reconcileCurrentType.is(value)) {
@@ -7099,7 +7107,7 @@ function union(optionsOrType) {
7099
7107
  otherTypes[_i - 1] = arguments[_i];
7100
7108
  }
7101
7109
  var options = isType(optionsOrType) ? undefined : optionsOrType;
7102
- var types = isType(optionsOrType) ? __spread([optionsOrType], otherTypes) : otherTypes;
7110
+ var types = isType(optionsOrType) ? __spreadArray([optionsOrType], __read(otherTypes), false) : otherTypes;
7103
7111
  var name = "(" + types.map(function (type) { return type.name; }).join(" | ") + ")";
7104
7112
  // check all options
7105
7113
  if (devMode()) {
@@ -7237,7 +7245,7 @@ var OptionalValue = /** @class */ (function (_super) {
7237
7245
  function checkOptionalPreconditions(type, defaultValueOrFunction) {
7238
7246
  // make sure we never pass direct instances
7239
7247
  if (typeof defaultValueOrFunction !== "function" && isStateTreeNode(defaultValueOrFunction)) {
7240
- throw fail$1("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead");
7248
+ throw fail("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead");
7241
7249
  }
7242
7250
  assertIsType(type, 1);
7243
7251
  if (devMode()) {
@@ -7376,10 +7384,10 @@ var Late = /** @class */ (function (_super) {
7376
7384
  throw e;
7377
7385
  }
7378
7386
  if (mustSucceed && t === undefined)
7379
- throw fail$1("Late type seems to be used too early, the definition (still) returns undefined");
7387
+ throw fail("Late type seems to be used too early, the definition (still) returns undefined");
7380
7388
  if (t) {
7381
7389
  if (devMode() && !isType(t))
7382
- throw fail$1("Failed to determine subtype, make sure types.late returns a type definition.");
7390
+ throw fail("Failed to determine subtype, make sure types.late returns a type definition.");
7383
7391
  this._subType = t;
7384
7392
  }
7385
7393
  }
@@ -7461,12 +7469,12 @@ var Late = /** @class */ (function (_super) {
7461
7469
  * @returns
7462
7470
  */
7463
7471
  function late(nameOrType, maybeType) {
7464
- var name = typeof nameOrType === "string" ? nameOrType : "late(" + nameOrType.toString() + ")";
7472
+ var name = typeof nameOrType === "string" ? nameOrType : "late(".concat(nameOrType.toString(), ")");
7465
7473
  var type = typeof nameOrType === "string" ? maybeType : nameOrType;
7466
7474
  // checks that the type is actually a late type
7467
7475
  if (devMode()) {
7468
7476
  if (!(typeof type === "function" && type.length === 0))
7469
- throw fail$1("Invalid late type, expected a function with zero arguments that returns a type, got: " +
7477
+ throw fail("Invalid late type, expected a function with zero arguments that returns a type, got: " +
7470
7478
  type);
7471
7479
  }
7472
7480
  return new Late(name, type);
@@ -7533,7 +7541,7 @@ var Lazy = /** @class */ (function (_super) {
7533
7541
  node.parent.applyPatches([
7534
7542
  {
7535
7543
  op: "replace",
7536
- path: "/" + node.subpath,
7544
+ path: "/".concat(node.subpath),
7537
7545
  value: node.snapshot
7538
7546
  }
7539
7547
  ]);
@@ -7547,7 +7555,7 @@ var Lazy = /** @class */ (function (_super) {
7547
7555
  configurable: true,
7548
7556
  writable: true,
7549
7557
  value: function () {
7550
- return "<lazy " + this.name + ">";
7558
+ return "<lazy ".concat(this.name, ">");
7551
7559
  }
7552
7560
  });
7553
7561
  Object.defineProperty(Lazy.prototype, "instantiate", {
@@ -7601,7 +7609,7 @@ var Lazy = /** @class */ (function (_super) {
7601
7609
  var Frozen = /** @class */ (function (_super) {
7602
7610
  __extends(Frozen, _super);
7603
7611
  function Frozen(subType) {
7604
- var _this = _super.call(this, subType ? "frozen(" + subType.name + ")" : "frozen") || this;
7612
+ var _this = _super.call(this, subType ? "frozen(".concat(subType.name, ")") : "frozen") || this;
7605
7613
  Object.defineProperty(_this, "subType", {
7606
7614
  enumerable: true,
7607
7615
  configurable: true,
@@ -7749,15 +7757,15 @@ var StoredReference = /** @class */ (function () {
7749
7757
  else if (isStateTreeNode(value)) {
7750
7758
  var targetNode = getStateTreeNode(value);
7751
7759
  if (!targetNode.identifierAttribute)
7752
- throw fail$1("Can only store references with a defined identifier attribute.");
7760
+ throw fail("Can only store references with a defined identifier attribute.");
7753
7761
  var id = targetNode.unnormalizedIdentifier;
7754
7762
  if (id === null || id === undefined) {
7755
- throw fail$1("Can only store references to tree nodes with a defined identifier.");
7763
+ throw fail("Can only store references to tree nodes with a defined identifier.");
7756
7764
  }
7757
7765
  this.identifier = id;
7758
7766
  }
7759
7767
  else {
7760
- throw fail$1("Can only store references to tree nodes or identifiers, got: '" + value + "'");
7768
+ throw fail("Can only store references to tree nodes or identifiers, got: '".concat(value, "'"));
7761
7769
  }
7762
7770
  }
7763
7771
  Object.defineProperty(StoredReference.prototype, "updateResolvedReference", {
@@ -7774,7 +7782,7 @@ var StoredReference = /** @class */ (function () {
7774
7782
  // reference was initialized with the identifier of the target
7775
7783
  var target = root.identifierCache.resolve(targetType, normalizedId);
7776
7784
  if (!target) {
7777
- throw new InvalidReferenceError("[mobx-state-tree] Failed to resolve reference '" + this.identifier + "' to type '" + this.targetType.name + "' (from node: " + node.path + ")");
7785
+ throw new InvalidReferenceError("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier, "' to type '").concat(this.targetType.name, "' (from node: ").concat(node.path, ")"));
7778
7786
  }
7779
7787
  this.resolvedReference = {
7780
7788
  node: target,
@@ -7813,7 +7821,7 @@ var InvalidReferenceError = /** @class */ (function (_super) {
7813
7821
  var BaseReferenceType = /** @class */ (function (_super) {
7814
7822
  __extends(BaseReferenceType, _super);
7815
7823
  function BaseReferenceType(targetType, onInvalidated) {
7816
- var _this = _super.call(this, "reference(" + targetType.name + ")") || this;
7824
+ var _this = _super.call(this, "reference(".concat(targetType.name, ")")) || this;
7817
7825
  Object.defineProperty(_this, "targetType", {
7818
7826
  enumerable: true,
7819
7827
  configurable: true,
@@ -8139,7 +8147,7 @@ function reference(subType, options) {
8139
8147
  if (devMode()) {
8140
8148
  if (arguments.length === 2 && typeof arguments[1] === "string") {
8141
8149
  // istanbul ignore next
8142
- throw fail$1("References with base path are no longer supported. Please remove the base path.");
8150
+ throw fail("References with base path are no longer supported. Please remove the base path.");
8143
8151
  }
8144
8152
  }
8145
8153
  var getSetOptions = options ? options : undefined;
@@ -8149,7 +8157,7 @@ function reference(subType, options) {
8149
8157
  if (getSetOptions && (getSetOptions.get || getSetOptions.set)) {
8150
8158
  if (devMode()) {
8151
8159
  if (!getSetOptions.get || !getSetOptions.set) {
8152
- throw fail$1("reference options must either contain both a 'get' and a 'set' method or none of them");
8160
+ throw fail("reference options must either contain both a 'get' and a 'set' method or none of them");
8153
8161
  }
8154
8162
  }
8155
8163
  return new CustomReferenceType(subType, {
@@ -8227,7 +8235,7 @@ var BaseIdentifierType = /** @class */ (function (_super) {
8227
8235
  writable: true,
8228
8236
  value: function (parent, subpath, environment, initialValue) {
8229
8237
  if (!parent || !(parent.type instanceof ModelType))
8230
- throw fail$1("Identifier types can only be instantiated as direct child of a model type");
8238
+ throw fail("Identifier types can only be instantiated as direct child of a model type");
8231
8239
  return createScalarNode(this, parent, subpath, environment, initialValue);
8232
8240
  }
8233
8241
  });
@@ -8238,7 +8246,7 @@ var BaseIdentifierType = /** @class */ (function (_super) {
8238
8246
  value: function (current, newValue, parent, subpath) {
8239
8247
  // we don't consider detaching here since identifier are scalar nodes, and scalar nodes cannot be detached
8240
8248
  if (current.storedValue !== newValue)
8241
- throw fail$1("Tried to change identifier from '" + current.storedValue + "' to '" + newValue + "'. Changing identifiers is not allowed.");
8249
+ throw fail("Tried to change identifier from '".concat(current.storedValue, "' to '").concat(newValue, "'. Changing identifiers is not allowed."));
8242
8250
  current.setParent(parent, subpath);
8243
8251
  return current;
8244
8252
  }
@@ -8249,7 +8257,7 @@ var BaseIdentifierType = /** @class */ (function (_super) {
8249
8257
  writable: true,
8250
8258
  value: function (value, context) {
8251
8259
  if (typeof value !== this.validType) {
8252
- return typeCheckFailure(context, value, "Value is not a valid " + this.describe() + ", expected a " + this.validType);
8260
+ return typeCheckFailure(context, value, "Value is not a valid ".concat(this.describe(), ", expected a ").concat(this.validType));
8253
8261
  }
8254
8262
  return typeCheckSuccess();
8255
8263
  }
@@ -8460,7 +8468,7 @@ var CustomType = /** @class */ (function (_super) {
8460
8468
  return typeCheckSuccess();
8461
8469
  var typeError = this.options.getValidationMessage(value);
8462
8470
  if (typeError) {
8463
- return typeCheckFailure(context, value, "Invalid value for type '" + this.name + "': " + typeError);
8471
+ return typeCheckFailure(context, value, "Invalid value for type '".concat(this.name, "': ").concat(typeError));
8464
8472
  }
8465
8473
  return typeCheckSuccess();
8466
8474
  }