0Pricing
TypeScript Academy · Lesson

Built-ins: ReturnType, Parameters, InstanceType, etc.

Know and apply key built-in utility types: ReturnType, Parameters, InstanceType, ThisParameterType, OmitThisParameter, ConstructorParameters.

Intro

Goal: Use built-in utility types efficiently. You'll map functions/constructors to their return, parameters, instance, and this types.

  • ReturnType, Parameters
  • InstanceType, ConstructorParameters
  • ThisParameterType, OmitThisParameter

ReturnType & Parameters

ReturnType infers the return type, Parameters the parameter tuple; reduces fragility in refactors.

function greet(name: string) { return `Hi ${name}` }

// built-ins
type R = ReturnType<typeof greet>        // string
type P = Parameters<typeof greet>        // [name: string]

All lessons in this course

  1. T extends U ? X : Y in practice
  2. infer for ReturnType-like utilities
  3. Built-ins: ReturnType, Parameters, InstanceType, etc.
← Back to TypeScript Academy