function-types
OmitThisParameter<T>
Returns a function type identical to T but without its explicit `this` parameter. Commonly paired with `Function.prototype.bind` to model the bound function's signature.
type OmitThisParameter<T> = unknown extends ThisParameterType<T> ? T : T extends (...args: infer A) => infer R ? (...args: A) => R : T Usage patterns
| Pattern | Purpose |
|---|---|
| OmitThisParameter<typeof fn> | Get the shape of the function after binding this |
| fn.bind(x) | Runtime operation whose type is modeled by this utility |
| ThisParameterType<T> | Read side companion — inspect vs remove |
| Parameters<OmitThisParameter<T>> | Get only the real args, minus this |
Examples
function toHex(this: number) { return this.toString(16); }
type Bound = OmitThisParameter<typeof toHex>; Result: () => string — this parameter removed
const bound: OmitThisParameter<typeof toHex> = toHex.bind(255); Type mirrors the runtime .bind call
function plain(x: number) { return x; }
type Same = OmitThisParameter<typeof plain>; Result: (x: number) => number — no-op when this is not declared
type Args = Parameters<OmitThisParameter<(this: Foo, a: 1) => 2>>; Result: [a: 1] — the this slot is gone
Gotcha
If the function has no explicit `this` parameter, T is returned unchanged. It only removes `this` — regular parameters and return type are preserved as-is.
Related utility types
ThisParameterType<T>
Extracts the explicit `this` parameter type from a function T, or `unknown` if none is declared. Useful for reflecting on method-style callbacks that require a specific caller.
Parameters<T>
Extracts the parameters of a function type T as a tuple. Enables reusing a function's argument list for wrappers, currying, or higher-order utilities.
ReturnType<T>
Infers the return type of a function type T using `infer R`. Widely used to derive types from existing functions without redeclaring them.
ThisType<T>
A marker interface with no members that, when used in a contextual type, sets the `this` type inside method-like properties of an object literal. Requires `noImplicitThis` to be genuinely useful and is a compile-time only hint.
ConstructorParameters<T>
Extracts the parameter tuple of a class constructor T. Mirrors Parameters but operates on `new (...)` signatures instead of call signatures.
← All TS utility types · TypeScript vs JavaScript · any vs unknown vs never