Skip to content

isTypeError ​

The isTypeError function checks if a value is an instance of TypeError.

Syntax ​

typescript
isTypeError(value: any): value is TypeError;

Parameters ​

NameTypeDescription
valueanyThe value to check

Returns ​

TypeDescription
booleantrue if the value is an instance of TypeError, false otherwise

Examples ​

typescript
isTypeError(new TypeError("Invalid type"));
// => true

isTypeError(new Error());
// => false

isTypeError({});
// => false

Notes ​

  • Useful for identifying type errors in JavaScript operations.

References ​

Released under the MIT License.