# 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`](https://error.angular-package.dev/generic-type-variables#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>](https://error.angular-package.dev/generic-type-variables#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`](https://error.angular-package.dev/generic-type-variables#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;
```
