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 typeK— Stands for "Key", typically used for object keysV— Stands for "Value", often paired withKin key-value scenariosE— Stands for "Element", common in collection typesR— 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:
TUserinstead of justTwhen specifically handling user typesTDatafor data payloadsTResponseandTRequestfor API patternsTConfigfor 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.