OmitThisParameter<T>

Removes the this parameter from function type T.

Since TS 3.3 Spec ↗

Syntax

OmitThisParameter<Type>

Returns

function type — The function type T with its this parameter removed.

Examples

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

type Plain = OmitThisParameter<typeof toHex>;
// () => string
const fiveToHex: OmitThisParameter<typeof toHex> =
  toHex.bind(5);

Notes

Returns the original type unchanged if there is no `this` parameter. Models the type of a function after `bind` has fixed its context. Pairs with `ThisParameterType` to inspect the removed parameter.

See also