> 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/accessors/get-type.md).

# get type()

## ​`TypeError.prototype.type`

The [`get`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get) accessor obtains the type of generic type variable [`Type`](/draft-5/typeerror/generic-type-variables.md#typeerror-less-than-id-type-greater-than-1) that causes an error to be thrown(or not thrown) if set, otherwise returns [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined).

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

```typescript
public get type(): Type | undefined {
  return this.#type;
}
```

{% endcode %}

### Return type

#### [<mark style="color:green;">`Type`</mark>](/draft-5/typeerror/generic-type-variables.md#typeerror-less-than-id-type-greater-than-1)`|`[<mark style="color:green;">`undefined`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#null-and-undefined)

### Returns

The **return value** is the type of generic type variable [`Type`](/draft-5/typeerror/generic-type-variables.md#typeerror-less-than-id-type-greater-than-1) or [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined).

## Example usage

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

// Returns "string".
new TypeError('problem', 'Fix accessor.', '(TE:201)', 'string').type;
```
