On this page
  1. ThisParameterType
  2. Syntax & Overview
  3. Notes & Pitfalls
  4. Example

ThisParameterType

Prev: `InstanceType` | Up: function_and_promise | Next: string_manipulation
Rel: function_and_promise, Conditional & Mapped Types
Ref: TypeScript Docs — Utility Types
Tags: #public #web #typescript #utility-types #function_and_promise #tier/specialized


Syntax & Overview

ThisParameterType<Fn>  /* + OmitThisParameter<Fn> */

Extracts the explicit this parameter type from a function signature (or unknown if none).

Notes & Pitfalls

Example

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

type ThisVal = ThisParameterType<typeof toHex>; // number
const val: ThisVal = 255;

Linked from

Related notes