assertInstance()function
assertInstance(value: unknown, type: Class<T>): asserts value is T
| Param | Type | |
|---|---|---|
value | unknown | The value to assert. required |
type | Class<T> | The class value must be an instance of. required |
| Return | |
|---|---|
asserts value is T |
| Throws | |
|---|---|
RequiredError | If value is not an instance of type. |
Assert that a value is an instance of something.
Examples
assertInstance(new Date(), Date); // passes