Object & Function Types

OmitThisParameter<T>

Removes the this parameter from a function type, producing a callable function signature without this context requirements.

Definition

TypeScript
type OmitThisParameter<T> =
  unknown extends ThisParameterType<T>
    ? T
    : T extends (...args: infer A) => infer R
      ? (...args: A) => R
      : T;

Examples

Removing this Parameter
function greet(this: { name: string }, greeting: string): string {
  return `${greeting}, ${this.name}!`;
}

type GreetFn = OmitThisParameter<typeof greet>;
// (greeting: string) => string

const boundGreet: GreetFn = greet.bind({ name: "Alice" });
console.log(boundGreet("Hello")); // "Hello, Alice!"
Safe Bind Wrapper
function safeBind<T extends (this: any, ...args: any[]) => any>(
  fn: T,
  thisArg: ThisParameterType<T>,
): OmitThisParameter<T> {
  return fn.bind(thisArg) as OmitThisParameter<T>;
}

function formatName(this: { first: string; last: string }): string {
  return `${this.first} ${this.last}`;
}

const format = safeBind(formatName, { first: "John", last: "Doe" });
console.log(format()); // "John Doe"
Event Handler Binding
class Button {
  label: string;
  constructor(label: string) { this.label = label; }

  handleClick(this: Button, event: MouseEvent): void {
    console.log(`${this.label} clicked`);
  }
}

type ClickHandler = OmitThisParameter<Button["handleClick"]>;
// (event: MouseEvent) => void

const btn = new Button("Submit");
const handler: ClickHandler = btn.handleClick.bind(btn);

Common Use Cases

  • 1Typing the result of Function.prototype.bind
  • 2Creating bound method references for event handlers
  • 3Removing this requirements for callback parameters
  • 4Framework code that pre-binds methods to instances
  • 5Converting prototype methods to standalone functions

Understanding OmitThisParameter<T>

OmitThisParameter<T> removes the this parameter from a function type, producing a new function type that can be called without specifying a this context. This is exactly what happens when you call Function.prototype.bind—the resulting function no longer needs a specific this value.

The implementation first checks whether T has a this parameter using ThisParameterType. If ThisParameterType<T> is unknown (meaning no explicit this), T is returned unchanged. Otherwise, it uses infer to capture the regular parameters and return type, constructing a new function type without this.

The primary use case is typing bound methods. When you call method.bind(context), the result is a function that no longer needs this—the context is already captured. OmitThisParameter<typeof method> gives you the correct type for this bound function.

This is particularly important in React class components and similar frameworks where event handlers need to be bound to the component instance. The bound handler's type is the original handler's type with this removed, which is exactly what OmitThisParameter expresses.

OmitThisParameter and ThisParameterType are complementary. ThisParameterType tells you what this should be, while OmitThisParameter gives you the function signature after this has been satisfied. Together, they enable type-safe implementations of bind, call, and apply wrappers.

In modern codebases that primarily use arrow functions and class fields, OmitThisParameter is less commonly needed directly. However, it remains important when working with libraries that use prototype methods or when building framework-level utilities that manage function binding.

Related Types

More Object & Function Types

Explore TypeScript Types

Browse our complete reference of 30 TypeScript utility types with definitions, examples, and explanations.