# `ThisParameterType<Type>`

> The `ThisParameterType<Type>` utility type in TypeScript extracts the type of the `this` parameter of a function type.

## How do I get the type of this from a function in TypeScript?

The utility type that extracts the type of the `this` parameter of a function type, or `unknown` if the function has no `this` parameter.

- Topic: Utility Types
- Type: utility type

## Example

Wrong:

```ts
function greet(this: User) {
  return this.name;
}
type Ctx = Parameters<typeof greet>[0];
```

Right:

```ts
function greet(this: User) {
  return this.name;
}
type Ctx = ThisParameterType<typeof greet>; // User
```

`Parameters` ignores the fake `this` parameter; `ThisParameterType` reads it directly.

## Common mistakes

- Reading `Parameters<typeof fn>[0]` and expecting the `this` type, which `Parameters` skips.

## Key points

- The function declares `this` as its first fake parameter, e.g. `function f(this: Window)`.
- Code handles `unknown`, the result for functions with no `this` parameter.

## Interview questions

### Does Parameters include the this parameter?

No, `Parameters<T>` returns only the real arguments. Use `ThisParameterType<T>` to get the `this` type.

### What does ThisParameterType return if there is no this parameter?

It returns `unknown`.

## Related cards

- [`OmitThisParameter<Type>`](https://wonderium.dev/ts/omitthisparameter.md)
- [`ThisType<Type>`](https://wonderium.dev/ts/thistype.md)
- [this](https://wonderium.dev/js/this.md)
- [.call()](https://wonderium.dev/js/call.md)
- [Function Types](https://wonderium.dev/ts/function.md)

---

- Level: [TypeScript](https://wonderium.dev/ts.md)
- HTML version: https://wonderium.dev/ts/thisparametertype
- Last updated: 2026-11-25
