TypeTags .TypeError

Overview

The TypeError object represents an error when an operation could not be performed, typically (but not exclusively) when a value is not of the expected type.

️🚫

Since error objects do not have unique type tags, a TypeError type tag is the same as any other Error object. If you need to check if an error is an instance of a TypeError, use instanceof instead.

Usage

import { TypeTags } from 'typetags'
try {
throw new TypeError('Hello', 'someFile.js', 10)
} catch (e) {
console.log(e instanceof TypeError) // true
TypeTags.get(e) === TypeTags.RangeError // → true
}
console.log(TypeTags.TypeError)
// → [object Error]

Metadata (TType)

MetadataValue
.typeTypeError
.tag[object Error]
.builtin()undefined
.getTag()[object Error]
.hasSpecialArgs()false
.instance()undefined
.instanceTypeOf()object
.info()see more
.isAvailable()true
.isConstructor()true
.isFactory()true
.isFunction()true
.isGlobal()true
.isIterator()false
.isNested()false
.isObject()false
.isPrimitive()false
.isStringifiable()true
.isSyntatic()false
.isTypedArray()false
.ownKeys()[length, name, prototype]
.toString()function toString() { [native code] }
.typeOf()function

Signature

declare type ITypeTags = {
[key in Types | NestedTypes]: Tags
}
declare interface Predicate {
predicate(value: any): boolean
}

See MDN Web Docs