Naming Conventions for Focused Types
What you'll learn: How to use descriptive names for small, focused types to prevent confusion as your type collection grows.
The Problem: Type Proliferation Confusion
When you break down large union types into smaller, more focused pieces (as you just learned), you can quickly end up with dozens of types in a single module. Without clear naming conventions, code becomes impossible to navigate:
// Which is which? What do these represent?
type Data = { id: string; value: number };
type Info = { id: string; value: number };
type Result = { id: string; value: number };
All three types look similar and have vague names. Without opening each definition, you can't tell what they represent or when to use them.
Clear Naming Strategies
1. Describe the Domain Concept
Name types after what they represent in your domain, not their structure:
// Bad: structural names
type StringNumberPair = { key: string; value: number };
// Good: domain names
type MetricReading = { key: string; value: number };
2. Use Suffixes for Type Categories
Establish patterns for different categories of types:
// States
type LoadingState = { status: "loading" };
type ErrorState = { status: "error"; message: string };
// Requests/Responses
type LoginRequest = { username: string; password: string };
type LoginResponse = { token: string; user: User };
// Configuration
type DatabaseConfig = { host: string; port: number };
3. Avoid Generic Noise Words
Words like Data, Info, Type, Object rarely add meaning:
// Vague
type UserData = { name: string };
type UserInfo = { name: string };
// Clear
type UserProfile = { name: string };
type AuthenticatedUser = { name: string; token: string };
The Mental Model: Names as Documentation
Think of type names like variable names in well-written code. The name should tell you what it represents and when to use it, without needing to read the definition. When you extract a focused type from a larger union, its name becomes crucial navigation documentation.
Good names make your type collection self-organizing. A developer scanning the file should immediately know which type fits their use case.
Key Takeaway: Descriptive, domain-focused names for small types transform a confusing proliferation of definitions into a self-documenting type library that's easy to navigate and maintain.