What is ReturnType?
ReturnType
is a TypeScript utility that extracts the return type from any function. Instead of manually defining what a function returns, it automatically captures and reuses that type.

How it works
Point ReturnType
at a function, and it gives you back the exact type that function returns. No guessing, no manual typing - it reads the function and mirrors its output type.
Say you havefetchUser()
that returns{ id: 1, name: "John", email: "john@example.com" }
. Usetype User = ReturnType<typeof fetchUser>
and nowUser
automatically becomes{ id: number; name: string; email: string }
.
Why use ReturnType?
- Auto-sync - When your function's return type changes, dependent types update automatically
- Single source of truth - The function defines the type, everything else follows
- Less maintenance - No need to manually update multiple type definitions
Real-world scenario
Your API function returns user data withid
,name
, andavatar
field. WithReturnType
, every type that depends on this function automatically includes the newavatar
field without you touching a single type definition.
When the function evolves
Add a new field to your function's return? Every type using ReturnType
automatically includes it. No manual updates needed.
Key Benefits
- Stays in sync - Types automatically reflect function changes
- Reduces errors - No mismatched types from manual definitions
- Saves time - Write the logic once, let TypeScript handle the types