Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Type Alias

ReturnType

ReturnType<Type> extracts the return type of a function type into a reusable type. It is globally available and was introduced in TypeScript 2.8.

Since
2.8

How it works

ReturnType<Type> is a built-in conditional utility type that extracts the result type from a function type. Pass a function declaration with typeof, or another function type directly; overloaded functions use the last signature for inference.

Syntax

ReturnType<Type>

Parameters

NameTypeDescription
Typefunction typeA function type whose return type should be extracted.

Returns

A type representing the return type of Type.

Key points

  • It creates a type alias for whatever result type the supplied function type produces.
  • ReturnType has been available since TypeScript 2.8.
  • No import is needed because ReturnType is globally available.
  • Overload inference is based on the final call signature.
  • Its overload behavior is connected to conditional-type inference rules.

Common mistakes

  • With overloads, ReturnType uses the final signature rather than selecting a return type from the particular call.

Example: Derive a function's result type

function loadUser(id: number) {
  return { id, name: `user-${id}` };
}

type User = ReturnType<typeof loadUser>;

const user: User = loadUser(42);
console.log(user.name);

The alias derives the object type returned by loadUser, so user is checked against that inferred shape.

When to use it

Reuse an API result type

Keep a separately declared state, cache, or adapter type synchronized with a function's inferred result.

Reflect a function declaration

Create a type from a named function without duplicating its implementation signature.

Work with overloads

Model the result of an overloaded API when the documented final signature is authoritative.

Interview questions

QWhat does ReturnType do, and how is it commonly used?

ReturnType<Type> constructs a type from the return type of a function type. For a named function value, use ReturnType<typeof fn> so typeof supplies its function type.

Follow-up: What happens with an overloaded function? ReturnType infers from the last signature, which is generally the catch-all overload.

QDoes ReturnType execute a function?

It is a type-level utility, so it does not call the function or change runtime behavior. It reuses the function's declared or inferred result type elsewhere in the program.

Follow-up: How can you obtain the return type of an inline function type? Write ReturnType<() => Result>, or use a compatible function type directly.

QWhen was ReturnType introduced?

The utility was released in TypeScript 2.8. It is globally available as one of TypeScript's predefined utility types.

Follow-up: Which related utility extracts a constructor's instance type? InstanceType performs that analogous operation for constructor functions.

  • InstanceType
  • Parameters
  • ConstructorParameters
  • Awaited

Source: Documentation - Utility Types - TypeScript. Checked 2026-10-15.