Contains utility functions for type guards.
| Function | Description |
|---|
| assert | Asserts that a condition is true. Throws if it is not. Use in place of /* v8 ignore *\/ for defensive guards that should never trigger at runtime but would otherwise create uncovered branches. |
| assertGenericObject | Asserts that a value is a generic object, narrowing its type in place. |
| assertNever | Asserts at compile time that every case of a discriminated union has been handled. Place at the default branch of a switch over a union or enum. If a new variant is added to the union without a matching case, the call to assertNever fails to compile because value is no longer never. If reached at runtime (e.g. because the value was bypassed via JSON or a type assertion), it throws a descriptive Error. |
| assertNonNullable | Asserts that a value is not null or undefined, narrowing its type in place. Only callable when T includes null or undefined. Passing an already non-nullable type is a compile error. |
| ensureGenericObject | Ensures that a value is a generic object, returning it with narrowed type. |
| ensureNonNullable | Ensures that a value is not null or undefined and returns it with narrowed type. Only callable when T includes null or undefined. Passing an already non-nullable type is a compile error. |
| Type | Description |
|---|
| GenericObject | A type that represents a generic object. |