> For the complete documentation index, see [llms.txt](https://error.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://error.angular-package.dev/draft-5/typeerror/methods/static-istypeerror.md).

# static isTypeError()

## `TypeError.isTypeError()`

Checks whether the [`value`](#value-any) of [`any`](https://www.typescriptlang.org/docs/handbook/basic-types.html#any) type is an instance of [`TypeError`](/draft-5/typeerror/overview.md) of any or the given [`type`](#type-type) and [identification](#id-id).

{% code title="type-error.class.ts" %}

```typescript
public static isTypeError<
  Id extends string,
  Type extends string | undefined = undefined
>(value: any, id?: Id, type?: Type): value is TypeError<Id, Type> {
  return (
    super.isError(value, id) &&
    (typeof type === 'string' ? (value as any).type === type : true)
  );
}
```

{% endcode %}

### Generic type variables

#### <mark style="color:green;">`Id`</mark>`extends`[<mark style="color:green;">`string`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#string)

A generic type variable constrained by the [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), by default of the value **captured** from the provided optional [`id`](#id-id) indicates the [identification](/draft-5/getting-started/basic-concepts.md#identification) type of the [`TypeError`](/draft-5/typeerror/overview.md) via [return type](#return-type).

#### <mark style="color:green;">`Type`</mark>`extends`[<mark style="color:green;">`string`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#string)`|`[<mark style="color:green;">`undefined`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined)`=`[<mark style="color:green;">`undefined`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined)&#x20;

A generic type variable constrained by the [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) and [`undefined`](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined), by default of the value equal to [`undefined`](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined) indicates the captured type of the supplied [`type`](#type-type) via [return type](#return-type).

### Parameters

#### `value:`[<mark style="color:green;">`any`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#any)

The value of [`any`](https://www.typescriptlang.org/docs/handbook/basic-types.html#any) type to check against the [`TypeError`](/draft-5/typeerror/overview.md) instance.

#### `id?:`[<mark style="color:green;">`Id`</mark>](#idextendsstring)

Optional unique [identification](/draft-5/getting-started/basic-concepts.md#identification) of generic type variable [`Id`](#idextendsstring) to check whether the given [`value`](#value-any) contains.

#### `type?:`[<mark style="color:green;">`Type`</mark>](#typeextendsstring-or-undefined-undefined)

The optional type of generic type variable [`Type`](#typeextendsstring-or-undefined-undefined) that causes an error to be thrown(or not thrown) to check whether the given [`value`](#value-any) contains.

### Return type

#### `value is TypeError<`[<mark style="color:green;">`Id`</mark>](#idextendsstring)`,`[<mark style="color:green;">`Type`</mark>](#typeextendsstring-or-undefined-undefined)`>`

The **return type** is a [`boolean`](https://www.typescriptlang.org/docs/handbook/basic-types.html#boolean) resulting from its statement indicating the [`value`](#value-any) is the [`TypeError`](/draft-5/typeerror/overview.md) object that takes the generic type variable [`Id`](#idextendsstring) as identification and generic type variable [`Type`](#typeextendsstring-or-undefined-undefined) as the type.

### Returns

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) type indicating whether the given [`value`](#value-any) is an instance of [`TypeError`](/draft-5/typeerror/overview.md) of any or the given optional [`type`](#type-type) and [`id`](#id-id) properties.

## Example usage

```typescript
// Example usage.
import { TypeError } from '@angular-package/error';

// Define error.
const err = TypeError.define('Wrong type', 'Change the type', 'TE:201', 'string');

// Returns true.
TypeError.isTypeError(err);

// Returns true.
TypeError.isTypeError(err, 'TE:201');

// Returns true.
TypeError.isTypeError(err, 'TE:201', 'string');

// Returns false.
TypeError.isTypeError(err, 'TE:202', 'number');

// Returns false.
TypeError.isTypeError(err, 'TE:202', 'string');

// Returns false.
TypeError.isTypeError(new Array());
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://error.angular-package.dev/draft-5/typeerror/methods/static-istypeerror.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
