@uxf/core 11.53.0 → 11.53.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/core",
3
- "version": "11.53.0",
3
+ "version": "11.53.1",
4
4
  "description": "UXF Core",
5
5
  "author": "Petr Vejvoda <vejvoda@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/core#readme",
@@ -1 +1 @@
1
- export declare function assertNever(value: never): undefined;
1
+ export declare function assertNever(value: never): never;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertNever = assertNever;
4
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+ const throw_error_1 = require("./throw-error");
5
5
  function assertNever(value) {
6
- return void null;
6
+ return (0, throw_error_1.throwError)(`Unhandled case: '${value}'`);
7
7
  }
@@ -1,9 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const assert_never_1 = require("./assert-never");
4
- test("assert-never", () => {
5
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
- // @ts-expect-error
7
- expect(() => (0, assert_never_1.assertNever)("test")).not.toThrow();
8
- expect(() => (0, assert_never_1.assertNever)(undefined)).not.toThrow();
4
+ var TestType;
5
+ (function (TestType) {
6
+ TestType["Example1"] = "EXAMPLE_1";
7
+ TestType["Example2"] = "EXAMPLE_2";
8
+ })(TestType || (TestType = {}));
9
+ function handleTestType(testType) {
10
+ switch (testType) {
11
+ case TestType.Example1:
12
+ return "Handled EXAMPLE_1";
13
+ case TestType.Example2:
14
+ return "Handled EXAMPLE_2";
15
+ default:
16
+ return (0, assert_never_1.assertNever)(testType);
17
+ }
18
+ }
19
+ test("assertNever", () => {
20
+ expect(handleTestType(TestType.Example1)).toBe("Handled EXAMPLE_1");
21
+ expect(handleTestType(TestType.Example2)).toBe("Handled EXAMPLE_2");
22
+ // Simulating an invalid input
23
+ expect(() => handleTestType("INVALID_TEST_TYPE")).toThrow();
24
+ expect(() => handleTestType(undefined)).toThrow();
9
25
  });