Type Parameter Naming Conventions
You'll learn: How to name your type parameters so your code stays readable and maintainable, even as your generics grow more complex.
The Standard Single-Letter Conventions
Just like you learned that variables should have meaningful names, type parameters also need names — but generic code follows its own conventions. The most common pattern uses single capital letters:
T– The default "Type" parameter. Use this for your first/only generic type.U– The second type when you need two (TandU, like alphabetical variables).K– Stands for "Key," typically used for object property keys.V– Stands for "Value," often paired withKfor key-value relationships.
These aren't TypeScript keywords — they're just community conventions, like naming loop counters i and j.
When Single Letters Work
Single letters are perfect when the relationship is obvious from context:
function identity<T>(value: T): T {
return value; // T is clearly "whatever type comes in"
}
function pair<T, U>(first: T, second: U): [T, U] {
return [first, second]; // Two unrelated types
}
When to Use Descriptive Names
As soon as your generic gets specific or domain-focused, use descriptive names:
function getUserById<User>(id: string): User {
// "User" is clearer than "T" here
}
function mapObject<InputType, OutputType>(/* ... */) {
// Much clearer than <T, U> in complex transformations
}
If someone reading your code would ask "what does T represent here?" — use a real word.
Key Takeaway: Start with T, U, K, V for simple generics. Switch to descriptive names like User or InputType when the type parameter has specific meaning in your domain.