Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Type Alias

ThisParameterType

ThisParameterType<Type> extracts a function's explicit this-parameter type. It returns unknown when the function type has no this parameter.

Since
3.3

How it works

ThisParameterType<Type> inspects a function type and extracts the type declared for its special this parameter. If the function declares no this parameter, the result is unknown; the utility is for extracting an existing contextual this type, not transforming another type.

Syntax

ThisParameterType<Type>

Parameters

NameTypeDescription
Typefunction typeA function type whose explicit this parameter should be extracted.

Returns

The type declared by the function's this parameter, or unknown when the function type has no this parameter.

Key points

  • Given a function type with an explicit this parameter, the utility returns that parameter's type.
  • When no explicit this parameter exists, the utility resolves to unknown rather than inferring an ordinary argument or lexical receiver.
  • Its purpose is to inspect a function signature and retrieve receiver information, not to map the function into a new transformed function type.
  • ThisType is the related contextual marker; it is not the same operation as extracting a declared this parameter.

Common mistakes

  • A function without an explicit this parameter produces unknown, so callers should not assume a usable receiver type.
  • Enable noImplicitThis when using this utility so contextual this typing is checked.

Example: Extract a function's this type

function toHex(this: Number) {
  return this.toString(16);
}

function numberToString(n: ThisParameterType<typeof toHex>) {
  return toHex.apply(n);
}

console.log(numberToString(255));

The extracted this type is used to type the value passed to apply.

When to use it

Type receiver arguments

Type the receiver supplied to Function.prototype.apply or call when a function declares an explicit this parameter.

Reuse function metadata

Derive a reusable receiver type from an existing function declaration without duplicating its annotation.

Model higher-order APIs

Build generic function helpers that inspect receiver requirements from a function type.

Interview questions

QWhat does ThisParameterType do?

It extracts the type of a function's special this parameter. If that parameter is absent, the result is unknown.

Follow-up: What happens for an arrow function? Its lexical this is not declared as a function this parameter, so this utility does not recover a receiver type from it.

QHow is it commonly used?

The type argument is normally a function type, often obtained with typeof from a function declaration. The resulting type can then annotate a receiver value passed through APIs such as apply.

Follow-up: How would you preserve both the receiver and ordinary arguments? Combine ThisParameterType with Parameters<Type> and an appropriate call signature.

QHow does it relate to ThisType<T>?

It was released in TypeScript 3.3. It differs from ThisType<T>, which is a marker used for contextual this typing in object literals rather than an extractor.

Follow-up: Why can ThisType<T> not replace it? ThisType<T> supplies contextual information; ThisParameterType reads a declared this parameter from a function type.

  • ThisType<T>
  • Parameters<Type>
  • OmitThisParameter<Type>

Source: Documentation - Utility Types - TypeScript. Checked 2026-10-15.