> 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/overview.md).

# Overview

The \`TypeError\` object

## `TypeError {}`

The `TypeError` object is an extension of the [`CommonError`](/draft-5/commonerror/overview.md) class and is thrown when an operation could not be performed, typically(but not exclusively) when a value is not of the expected type, with the [message](/draft-5/commonerror/accessors/get-message.md) built from the described problem and its solution, optional an explicit identification and type, on the given or stored template.

{% embed url="<https://github.com/angular-package/error/blob/main/src/lib/type-error.class.ts>" %}
`type-error.class.ts`
{% endembed %}

### Accessors

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><strong>public get</strong> <a href="/draft-5/typeerror/accessors/get-name.md"><strong>name()</strong></a><strong>:</strong> <mark style="color:green;">string</mark><br>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get"><code>get</code></a> accessor obtains error name of a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String"><code>string</code></a> type, set to <code>'TypeError'</code> that is being thrown.</p>                                                                                                                                                                                                                                                 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| <p><strong>public get</strong> <a href="/draft-5/typeerror/accessors/get-type.md"><strong>type()</strong></a><strong>:</strong> <mark style="color:green;">Type</mark>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | <mark style="color:green;">undefined</mark><br>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get"><code>get</code></a> accessor obtains the type of generic type variable <a href="/draft-5/typeerror/generic-type-variables.md#typeerror-less-than-id-type-greater-than-1"><code>Type</code></a> that causes an error to be thrown(or not thrown) if set, otherwise returns <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined"><code>undefined</code></a>.</p> |
| <p><strong>public get</strong> <a href="/draft-5/typeerror/accessors/get-symbol.tostringtag.md"><strong>[Symbol.</strong><mark style="color:blue;"><strong>toStringTag</strong></mark><strong>](https://error.angular-package.dev/draft-5/typeerror)</strong></a><strong>:</strong> <mark style="color:green;">string</mark><br>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get"><code>get</code></a> accessor, with the help of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag"><code>toStringTag</code></a>, changes the default tag to <code>'TypeError'</code> for an instance of <a href="/draft-5/typeerror/overview.md"><code>TypeError</code></a>.</p> |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

### Properties

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><strong>public static</strong> <a href="/draft-5/typeerror/properties/static-template.md"><strong>template</strong></a><strong>:</strong> <mark style="color:green;">string</mark><br>A template of the error message of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String"><code>string</code></a> type with the replaceable <a href="/draft-5/commonerror/properties/static-template.md#problem"><code>{problem}</code></a>, <a href="/draft-5/commonerror/properties/static-template.md#fix"><code>{fix}</code></a> and optional <a href="/draft-5/commonerror/properties/static-template.md#id"><code>{id}</code></a>, <a href="/draft-5/commonerror/properties/static-template.md#max"><code>{max}</code></a>, <a href="/draft-5/commonerror/properties/static-template.md#min"><code>{min}</code></a>, <a href="/draft-5/commonerror/properties/static-template.md#type"><code>{type}</code></a> tags.</p> |
| <p><a href="/draft-5/typeerror/properties/type.md"><strong>#type?</strong></a><strong>:</strong> <mark style="color:green;">string</mark><br>Private <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string-type</a> property of the type that causes an error to be thrown(or not thrown).</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

### Methods

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong>public static</strong> <a href="/draft-5/typeerror/methods/static-define.md"><strong>define()</strong></a><strong>:</strong> <mark style="color:green;">TypeError</mark><<mark style="color:green;">Id</mark>, <mark style="color:green;">Type</mark>><br>Defines the <a href="/draft-5/typeerror/overview.md"><code>TypeError</code></a> instance with the <a href="/draft-5/commonerror/accessors/get-message.md">message</a> built of the given required <a href="/draft-5/typeerror/methods/static-define.md#problem-string"><code>problem</code></a>, <a href="/draft-5/typeerror/methods/static-define.md#fix-string"><code>fix</code></a> and optional <a href="/draft-5/typeerror/methods/static-define.md#id-id"><code>id</code></a> and <a href="/draft-5/typeerror/methods/static-define.md#type-type"><code>type</code></a> on the given or stored <a href="/pages/QO0W5kr9Si42Q6UmxCju#template-typeerror.template"><code>template</code></a>.</p> |
| <p><strong>public static</strong> <a href="/draft-5/typeerror/methods/static-istypeerror.md"><strong>isTypeError()</strong></a><strong>:</strong> value is <mark style="color:green;">TypeError</mark><<mark style="color:green;">Id</mark>, <mark style="color:green;">Type</mark>><br>Checks whether the <a href="/draft-5/typeerror/methods/static-istypeerror.md#value-any"><code>value</code></a> of <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html#any"><code>any</code></a> type is an instance of <a href="/draft-5/typeerror/overview.md"><code>TypeError</code></a> of any or the given <a href="/draft-5/typeerror/methods/static-istypeerror.md#type-type"><code>type</code></a> and <a href="/draft-5/typeerror/methods/static-istypeerror.md#id-id">identification</a>.</p>                                                                                                                                                          |
