@rightcapital/assert 2.1.3-feature-assertion-helpers-api-refinement.2357.1.0 → 2.1.3-feature-rename-assert-error-to-assertion-error.2367.1.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.
- package/README.md +5 -5
- package/lib/index.d.ts +9 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -13
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/assert/SKILL.md +7 -7
- package/src/index.ts +11 -11
package/README.md
CHANGED
|
@@ -95,17 +95,17 @@ assertNonNullable(user, 'User cannot be null');
|
|
|
95
95
|
// `user` is narrowed to NonNullable<User>
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
### Error Handling (`
|
|
98
|
+
### Error Handling (`AssertionError`)
|
|
99
99
|
|
|
100
|
-
All assertion functions throw `
|
|
100
|
+
All assertion functions throw `AssertionError` (which extends `Error`) when an assertion fails.
|
|
101
101
|
|
|
102
102
|
```typescript
|
|
103
|
-
import { assert,
|
|
103
|
+
import { assert, AssertionError } from '@rightcapital/assert';
|
|
104
104
|
|
|
105
105
|
try {
|
|
106
106
|
assert(user.age >= 18, 'User must be at least 18 years old');
|
|
107
107
|
} catch (error) {
|
|
108
|
-
if (error instanceof
|
|
108
|
+
if (error instanceof AssertionError) {
|
|
109
109
|
console.error('Assertion failed:', error.message);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -115,7 +115,7 @@ try {
|
|
|
115
115
|
|
|
116
116
|
| API | Return / Type Behavior | Typical Use Case |
|
|
117
117
|
| :------------------------------- | :-------------------------------- | :---------------------------------------------------- |
|
|
118
|
-
| `
|
|
118
|
+
| `AssertionError` | `class extends Error` | Error thrown on assertion failure |
|
|
119
119
|
| `assertExhaustive(value, msg?)` | `never` | Enforce exhaustiveness check in `switch` or `if-else` |
|
|
120
120
|
| `assertUnreachable(msg?)` | `never` | Mark logically unreachable code branches |
|
|
121
121
|
| `ensure(value, predicate, msg?)` | `S extends T` | Validate and return value with narrowed type |
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Assertion functions provide type-safe assertions and validation.
|
|
3
|
-
* When assertions fail, they throw `
|
|
3
|
+
* When assertions fail, they throw `AssertionError`.
|
|
4
4
|
*
|
|
5
5
|
* @author lixiaoyan <lxy.lixiaoyan@gmail.com>
|
|
6
6
|
* @example
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
/**
|
|
21
21
|
* Error thrown when an assertion fails.
|
|
22
22
|
*/
|
|
23
|
-
export declare class
|
|
24
|
-
readonly name = "
|
|
23
|
+
export declare class AssertionError extends Error {
|
|
24
|
+
readonly name = "AssertionError";
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Basic assertion: verifies that a value or expression is `true`, otherwise throws an exception.
|
|
28
28
|
*
|
|
29
29
|
* @param value - The value to assert as truthy
|
|
30
30
|
* @param message - Optional custom error message
|
|
31
|
-
* @throws {
|
|
31
|
+
* @throws {AssertionError} Throws an error if `value` is not `true`.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```typescript
|
|
@@ -47,7 +47,7 @@ export declare function assert(value: unknown, message?: string): asserts value;
|
|
|
47
47
|
*
|
|
48
48
|
* @param value - The value to check for null/undefined
|
|
49
49
|
* @param message - Optional custom error message
|
|
50
|
-
* @throws {
|
|
50
|
+
* @throws {AssertionError} Throws an error if `value` is `null` or `undefined`.
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
53
|
* ```typescript
|
|
@@ -66,7 +66,7 @@ export declare function assertNonNullable<T>(value: T, message?: string): assert
|
|
|
66
66
|
* @param predicate - Type guard function that validates the value
|
|
67
67
|
* @param message - Optional custom error message
|
|
68
68
|
* @returns The value with narrowed type
|
|
69
|
-
* @throws {
|
|
69
|
+
* @throws {AssertionError} Throws an error if `predicate` returns `false`.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```typescript
|
|
@@ -91,7 +91,7 @@ export declare function ensure<T, S extends T>(value: T, predicate: (value: T) =
|
|
|
91
91
|
* @param value - The value to check for null/undefined
|
|
92
92
|
* @param message - Optional custom error message
|
|
93
93
|
* @returns The non-nullable value
|
|
94
|
-
* @throws {
|
|
94
|
+
* @throws {AssertionError} Throws an error if `value` is `null` or `undefined`.
|
|
95
95
|
*
|
|
96
96
|
* @example
|
|
97
97
|
* ```typescript
|
|
@@ -112,7 +112,7 @@ export declare function ensureNonNullable<T>(value: T, message?: string): NonNul
|
|
|
112
112
|
*
|
|
113
113
|
* @param message - Optional custom error message
|
|
114
114
|
* @returns Never returns (always throws)
|
|
115
|
-
* @throws {
|
|
115
|
+
* @throws {AssertionError} Always thrown.
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
118
118
|
* ```typescript
|
|
@@ -136,7 +136,7 @@ export declare function assertUnreachable(message?: string): never;
|
|
|
136
136
|
* @param value - The value that should be `never` if all cases are handled
|
|
137
137
|
* @param message - Optional custom error message
|
|
138
138
|
* @returns Never returns (always throws)
|
|
139
|
-
* @throws {
|
|
139
|
+
* @throws {AssertionError} Always thrown.
|
|
140
140
|
*
|
|
141
141
|
* @example
|
|
142
142
|
* ```typescript
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;GAEG;AACH,qBAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAyB,IAAI,oBAAoB;CAClD;AAaD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAItE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAIjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EACnC,KAAK,EAAE,CAAC,EACR,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,EACnC,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,CAGH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,MAAM,GACf,WAAW,CAAC,CAAC,CAAC,CAKhB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAEzD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAEtE"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Assertion functions provide type-safe assertions and validation.
|
|
4
|
-
* When assertions fail, they throw `
|
|
4
|
+
* When assertions fail, they throw `AssertionError`.
|
|
5
5
|
*
|
|
6
6
|
* @author lixiaoyan <lxy.lixiaoyan@gmail.com>
|
|
7
7
|
* @example
|
|
@@ -19,29 +19,29 @@
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.assertExhaustive = exports.assertUnreachable = exports.ensureNonNullable = exports.ensure = exports.assertNonNullable = exports.assert = exports.
|
|
22
|
+
exports.assertExhaustive = exports.assertUnreachable = exports.ensureNonNullable = exports.ensure = exports.assertNonNullable = exports.assert = exports.AssertionError = void 0;
|
|
23
23
|
/**
|
|
24
24
|
* Error thrown when an assertion fails.
|
|
25
25
|
*/
|
|
26
|
-
class
|
|
26
|
+
class AssertionError extends Error {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
|
-
this.name = '
|
|
29
|
+
this.name = 'AssertionError';
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
exports.
|
|
32
|
+
exports.AssertionError = AssertionError;
|
|
33
33
|
/**
|
|
34
|
-
* Throws an
|
|
34
|
+
* Throws an AssertionError for failed assertions.
|
|
35
35
|
*/
|
|
36
36
|
function throwError(name, value, message) {
|
|
37
|
-
throw new
|
|
37
|
+
throw new AssertionError(message !== null && message !== void 0 ? message : `${name}: Unexpected ${String(value)}`);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Basic assertion: verifies that a value or expression is `true`, otherwise throws an exception.
|
|
41
41
|
*
|
|
42
42
|
* @param value - The value to assert as truthy
|
|
43
43
|
* @param message - Optional custom error message
|
|
44
|
-
* @throws {
|
|
44
|
+
* @throws {AssertionError} Throws an error if `value` is not `true`.
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
47
|
* ```typescript
|
|
@@ -65,7 +65,7 @@ exports.assert = assert;
|
|
|
65
65
|
*
|
|
66
66
|
* @param value - The value to check for null/undefined
|
|
67
67
|
* @param message - Optional custom error message
|
|
68
|
-
* @throws {
|
|
68
|
+
* @throws {AssertionError} Throws an error if `value` is `null` or `undefined`.
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
71
|
* ```typescript
|
|
@@ -89,7 +89,7 @@ exports.assertNonNullable = assertNonNullable;
|
|
|
89
89
|
* @param predicate - Type guard function that validates the value
|
|
90
90
|
* @param message - Optional custom error message
|
|
91
91
|
* @returns The value with narrowed type
|
|
92
|
-
* @throws {
|
|
92
|
+
* @throws {AssertionError} Throws an error if `predicate` returns `false`.
|
|
93
93
|
*
|
|
94
94
|
* @example
|
|
95
95
|
* ```typescript
|
|
@@ -118,7 +118,7 @@ exports.ensure = ensure;
|
|
|
118
118
|
* @param value - The value to check for null/undefined
|
|
119
119
|
* @param message - Optional custom error message
|
|
120
120
|
* @returns The non-nullable value
|
|
121
|
-
* @throws {
|
|
121
|
+
* @throws {AssertionError} Throws an error if `value` is `null` or `undefined`.
|
|
122
122
|
*
|
|
123
123
|
* @example
|
|
124
124
|
* ```typescript
|
|
@@ -145,7 +145,7 @@ exports.ensureNonNullable = ensureNonNullable;
|
|
|
145
145
|
*
|
|
146
146
|
* @param message - Optional custom error message
|
|
147
147
|
* @returns Never returns (always throws)
|
|
148
|
-
* @throws {
|
|
148
|
+
* @throws {AssertionError} Always thrown.
|
|
149
149
|
*
|
|
150
150
|
* @example
|
|
151
151
|
* ```typescript
|
|
@@ -172,7 +172,7 @@ exports.assertUnreachable = assertUnreachable;
|
|
|
172
172
|
* @param value - The value that should be `never` if all cases are handled
|
|
173
173
|
* @param message - Optional custom error message
|
|
174
174
|
* @returns Never returns (always throws)
|
|
175
|
-
* @throws {
|
|
175
|
+
* @throws {AssertionError} Always thrown.
|
|
176
176
|
*
|
|
177
177
|
* @example
|
|
178
178
|
* ```typescript
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAEH;;GAEG;AACH,MAAa,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAEH;;GAEG;AACH,MAAa,cAAe,SAAQ,KAAK;IAAzC;;QAC2B,SAAI,GAAG,gBAAgB,CAAC;IACnD,CAAC;CAAA;AAFD,wCAEC;AAED;;GAEG;AACH,SAAS,UAAU,CACjB,IAAY,EACZ,KAAc,EACd,OAA2B;IAE3B,MAAM,IAAI,cAAc,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,GAAG,IAAI,gBAAgB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,MAAM,CAAC,KAAc,EAAE,OAAgB;IACrD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAJD,wBAIC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,iBAAiB,CAC/B,KAAQ,EACR,OAAgB;IAEhB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,UAAU,CAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;AACH,CAAC;AAPD,8CAOC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,MAAM,CACpB,KAAQ,EACR,SAAmC,EACnC,OAAgB;IAEhB,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,wBAOC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,iBAAiB,CAC/B,KAAQ,EACR,OAAgB;IAEhB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,UAAU,CAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AARD,8CAQC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,UAAU,CAAC,mBAAmB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAFD,8CAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,gBAAgB,CAAC,KAAY,EAAE,OAAgB;IAC7D,UAAU,CAAC,kBAAkB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAFD,4CAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rightcapital/assert",
|
|
3
|
-
"version": "2.1.3-feature-
|
|
3
|
+
"version": "2.1.3-feature-rename-assert-error-to-assertion-error.2367.1.0",
|
|
4
4
|
"description": "Type-safe assertion utilities for defensive programming.",
|
|
5
5
|
"author": "RightCapital Ecosystem team <npm-publisher@rightcapital.com>",
|
|
6
6
|
"keywords": [
|
package/skills/assert/SKILL.md
CHANGED
|
@@ -12,14 +12,14 @@ metadata:
|
|
|
12
12
|
|
|
13
13
|
# assert
|
|
14
14
|
|
|
15
|
-
Type-safe assertion utilities for defensive TypeScript programming. All functions throw `
|
|
15
|
+
Type-safe assertion utilities for defensive TypeScript programming. All functions throw `AssertionError` (which extends `Error`) on failure. Default error message format is `${functionName}: Unexpected ${String(value)}`.
|
|
16
16
|
|
|
17
17
|
## Import
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
20
|
import {
|
|
21
21
|
assert,
|
|
22
|
-
|
|
22
|
+
AssertionError,
|
|
23
23
|
assertExhaustive,
|
|
24
24
|
assertNonNullable,
|
|
25
25
|
assertUnreachable,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
|
|
33
33
|
| Class / Function | Signature / Return | Use Case |
|
|
34
34
|
| -------------------------------- | --------------------------------- | ------------------------------------------------------------------- |
|
|
35
|
-
| `
|
|
35
|
+
| `AssertionError` | `class extends Error` | Error type thrown when any assertion in this package fails. |
|
|
36
36
|
| `assert(value, msg?)` | `asserts value` | Precondition or boolean check (verifies `value === true`). |
|
|
37
37
|
| `assertNonNullable(value, msg?)` | `asserts value is NonNullable<T>` | Guard statement against `null` or `undefined`. |
|
|
38
38
|
| `ensure(value, predicate, msg?)` | `S extends T` | Inline validation using type guard function `(val: T) => val is S`. |
|
|
@@ -40,17 +40,17 @@ import {
|
|
|
40
40
|
| `assertExhaustive(value, msg?)` | `value: never` -> `never` | Exhaustiveness check in `switch` `default` case or `if-else` chain. |
|
|
41
41
|
| `assertUnreachable(msg?)` | `never` | Mark logically impossible code paths. |
|
|
42
42
|
|
|
43
|
-
## Error Handling with `
|
|
43
|
+
## Error Handling with `AssertionError`
|
|
44
44
|
|
|
45
|
-
All assertion functions throw `
|
|
45
|
+
All assertion functions throw `AssertionError` when a condition is not met. Use `instanceof AssertionError` to catch assertion failures specifically:
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
|
-
import { assert,
|
|
48
|
+
import { assert, AssertionError } from '@rightcapital/assert';
|
|
49
49
|
|
|
50
50
|
try {
|
|
51
51
|
assert(age >= 18, 'User must be an adult');
|
|
52
52
|
} catch (error) {
|
|
53
|
-
if (error instanceof
|
|
53
|
+
if (error instanceof AssertionError) {
|
|
54
54
|
console.error('Assertion failed:', error.message);
|
|
55
55
|
} else {
|
|
56
56
|
throw error;
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Assertion functions provide type-safe assertions and validation.
|
|
3
|
-
* When assertions fail, they throw `
|
|
3
|
+
* When assertions fail, they throw `AssertionError`.
|
|
4
4
|
*
|
|
5
5
|
* @author lixiaoyan <lxy.lixiaoyan@gmail.com>
|
|
6
6
|
* @example
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
/**
|
|
22
22
|
* Error thrown when an assertion fails.
|
|
23
23
|
*/
|
|
24
|
-
export class
|
|
25
|
-
public override readonly name = '
|
|
24
|
+
export class AssertionError extends Error {
|
|
25
|
+
public override readonly name = 'AssertionError';
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Throws an
|
|
29
|
+
* Throws an AssertionError for failed assertions.
|
|
30
30
|
*/
|
|
31
31
|
function throwError(
|
|
32
32
|
name: string,
|
|
33
33
|
value: unknown,
|
|
34
34
|
message: string | undefined,
|
|
35
35
|
): never {
|
|
36
|
-
throw new
|
|
36
|
+
throw new AssertionError(message ?? `${name}: Unexpected ${String(value)}`);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -41,7 +41,7 @@ function throwError(
|
|
|
41
41
|
*
|
|
42
42
|
* @param value - The value to assert as truthy
|
|
43
43
|
* @param message - Optional custom error message
|
|
44
|
-
* @throws {
|
|
44
|
+
* @throws {AssertionError} Throws an error if `value` is not `true`.
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
47
|
* ```typescript
|
|
@@ -65,7 +65,7 @@ export function assert(value: unknown, message?: string): asserts value {
|
|
|
65
65
|
*
|
|
66
66
|
* @param value - The value to check for null/undefined
|
|
67
67
|
* @param message - Optional custom error message
|
|
68
|
-
* @throws {
|
|
68
|
+
* @throws {AssertionError} Throws an error if `value` is `null` or `undefined`.
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
71
|
* ```typescript
|
|
@@ -92,7 +92,7 @@ export function assertNonNullable<T>(
|
|
|
92
92
|
* @param predicate - Type guard function that validates the value
|
|
93
93
|
* @param message - Optional custom error message
|
|
94
94
|
* @returns The value with narrowed type
|
|
95
|
-
* @throws {
|
|
95
|
+
* @throws {AssertionError} Throws an error if `predicate` returns `false`.
|
|
96
96
|
*
|
|
97
97
|
* @example
|
|
98
98
|
* ```typescript
|
|
@@ -125,7 +125,7 @@ export function ensure<T, S extends T>(
|
|
|
125
125
|
* @param value - The value to check for null/undefined
|
|
126
126
|
* @param message - Optional custom error message
|
|
127
127
|
* @returns The non-nullable value
|
|
128
|
-
* @throws {
|
|
128
|
+
* @throws {AssertionError} Throws an error if `value` is `null` or `undefined`.
|
|
129
129
|
*
|
|
130
130
|
* @example
|
|
131
131
|
* ```typescript
|
|
@@ -155,7 +155,7 @@ export function ensureNonNullable<T>(
|
|
|
155
155
|
*
|
|
156
156
|
* @param message - Optional custom error message
|
|
157
157
|
* @returns Never returns (always throws)
|
|
158
|
-
* @throws {
|
|
158
|
+
* @throws {AssertionError} Always thrown.
|
|
159
159
|
*
|
|
160
160
|
* @example
|
|
161
161
|
* ```typescript
|
|
@@ -182,7 +182,7 @@ export function assertUnreachable(message?: string): never {
|
|
|
182
182
|
* @param value - The value that should be `never` if all cases are handled
|
|
183
183
|
* @param message - Optional custom error message
|
|
184
184
|
* @returns Never returns (always throws)
|
|
185
|
-
* @throws {
|
|
185
|
+
* @throws {AssertionError} Always thrown.
|
|
186
186
|
*
|
|
187
187
|
* @example
|
|
188
188
|
* ```typescript
|