mobx-state-tree 7.3.2 → 7.4.0

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.
@@ -7459,13 +7459,14 @@ function isRefinementType(type) {
7459
7459
  }
7460
7460
 
7461
7461
  /**
7462
- * `types.enumeration` - Can be used to create an string based enumeration.
7463
- * (note: this methods is just sugar for a union of string literals)
7462
+ * `types.enumeration` - Can be used to create a string or number based enumeration.
7463
+ * (note: this methods is just sugar for a union of string or number literals)
7464
7464
  *
7465
7465
  * Example:
7466
7466
  * ```ts
7467
7467
  * const TrafficLight = types.model({
7468
- * color: types.enumeration("Color", ["Red", "Orange", "Green"])
7468
+ * color: types.enumeration("Color", ["Red", "Orange", "Green"]),
7469
+ * speedLimit: types.enumeration("SpeedLimit", [30, 50])
7469
7470
  * })
7470
7471
  * ```
7471
7472
  *
@@ -7478,10 +7479,10 @@ function enumeration(name, options) {
7478
7479
  // check all options
7479
7480
  if (devMode()) {
7480
7481
  realOptions.forEach(function (option, i) {
7481
- assertIsString(option, i + 1);
7482
+ assertArg(option, function (o) { return typeof o === "string" || typeof o === "number"; }, "string or number", i + 1);
7482
7483
  });
7483
7484
  }
7484
- var type = union.apply(void 0, __spreadArray([], __read(realOptions.map(function (option) { return literal("" + option); })), false));
7485
+ var type = union.apply(void 0, __spreadArray([], __read(realOptions.map(function (option) { return literal(option); })), false));
7485
7486
  if (typeof name === "string")
7486
7487
  type.name = name;
7487
7488
  return type;
@@ -7441,13 +7441,14 @@
7441
7441
  }
7442
7442
 
7443
7443
  /**
7444
- * `types.enumeration` - Can be used to create an string based enumeration.
7445
- * (note: this methods is just sugar for a union of string literals)
7444
+ * `types.enumeration` - Can be used to create a string or number based enumeration.
7445
+ * (note: this methods is just sugar for a union of string or number literals)
7446
7446
  *
7447
7447
  * Example:
7448
7448
  * ```ts
7449
7449
  * const TrafficLight = types.model({
7450
- * color: types.enumeration("Color", ["Red", "Orange", "Green"])
7450
+ * color: types.enumeration("Color", ["Red", "Orange", "Green"]),
7451
+ * speedLimit: types.enumeration("SpeedLimit", [30, 50])
7451
7452
  * })
7452
7453
  * ```
7453
7454
  *
@@ -7460,10 +7461,10 @@
7460
7461
  // check all options
7461
7462
  {
7462
7463
  realOptions.forEach(function (option, i) {
7463
- assertIsString(option, i + 1);
7464
+ assertArg(option, function (o) { return typeof o === "string" || typeof o === "number"; }, "string or number", i + 1);
7464
7465
  });
7465
7466
  }
7466
- var type = union.apply(void 0, __spreadArray([], __read(realOptions.map(function (option) { return literal("" + option); })), false));
7467
+ var type = union.apply(void 0, __spreadArray([], __read(realOptions.map(function (option) { return literal(option); })), false));
7467
7468
  if (typeof name === "string")
7468
7469
  type.name = name;
7469
7470
  return type;