Skip to content

assertInstanceOf

Assertion function that checks if a value is an instance of a given class, with type-narrowing.

import { assertInstanceOf } from "@kensio/smartass";
const error: unknown = new Error("Boom");
assertInstanceOf(error, Error);
// error is now narrowed to Error

Source file: src/assert/instance-of/instance-of.assert.ts