Interfaces
- Selector:
interface - Required:
PascalCase - Custom: forbids prefix
I*/T*whenI/Tis followed by uppercase
Why This Rule
PascalCase: Consistent with all other types (classes, type aliases), making the codebase uniform.
No I* prefix: The I prefix (inherited from C# and Java) is redundant in TypeScript:
- Your editor shows the type: Hover reveals whether something is an interface, type, or class
- TypeScript is structurally typed: The distinction between interface and type is often irrelevant
- Refactoring pain: Changing from
interfacetotypeshouldn't require renaming everything - Noise without value:
IUservsUser- the prefix adds no information the type system doesn't already provide
Modern TypeScript codebases overwhelmingly reject the I prefix. It's a holdover from languages where the distinction between abstract and concrete types is more critical.
Note: Prefixes like IFrame or Identifiable are allowed because they're actual words, not type prefixes.
References:
- This TS naming convention is weird - Matt Pocock - section about I and T prefixes
- TypeScript ESLint - Naming Convention for Interfaces
- TypeScript Deep Dive - Interfaces
- Avoid the
Iprefix for interfaces - Mário S. Camargo - detailed explanation - Microsoft TypeScript Coding Guidelines - explicitly avoids
Iprefix
✅ Good
ts
interface UserProfile {
// WHY: PascalCase interface with no `I` prefix
id: string;
}
interface Identifiable {
// WHY: A real word starting with I is allowed; it's not a type-prefix
id: string;
}❌ Bad
ts
interface IUserProfile {
// WHY: `I` prefix is redundant and discouraged
id: string;
}
interface I_Trailing {
// WHY: odd prefixing with underscores and I makes names noisy
id: string;
}