Course contentsShow
← TypeScript
Lesson 528 of 1,79613. GenericsFree lesson

Type Parameter Naming Conventions

Understanding common conventions like T, K, V, and when to use descriptive names like TUser or TData.

Type Parameter Naming Conventions

You'll learn: The standard naming conventions for type parameters and when to use short names versus descriptive ones.

Why Naming Matters

When you write a generic function or type, you introduce type parameters (those placeholders in angle brackets). Just like variable naming, there are conventions that make your code easier to read and understand for other developers—and your future self.

The Standard Single-Letter Conventions

The TypeScript community follows these traditional generic naming patterns:

  • T — The default "Type" parameter, used for any generic type
  • K — Stands for "Key", typically used for object keys
  • V — Stands for "Value", often paired with K in key-value scenarios
  • E — Stands for "Element", common in collection types
  • R — Stands for "Return type" in advanced scenarios

These single letters work well when the purpose is obvious from context. Think of them like pronouns—they reference something clear nearby.

When to Use Descriptive Names

For complex generics or when multiple type parameters appear, descriptive names improve clarity:

  • TUser instead of just T when specifically handling user types
  • TData for data payloads
  • TResponse and TRequest for API patterns
  • TConfig for configuration objects

The T prefix is a common convention (borrowed from C++ templates) to signal "this is a type parameter," not a concrete type.

Choosing the Right Approach

Use single letters for simple, obvious cases. Use descriptive names when they add genuine clarity—especially when teaching, documenting, or when you have three or more type parameters.

Key Takeaway: Follow the T, K, V conventions for simple generics, but don't hesitate to use descriptive names like TUser or TData when they make your intent clearer.