🔥 Naming Interfaces in TypeScript: IUser vs User

mpotapov

Mikhail Potapov

Posted on May 17, 2023

🔥 Naming Interfaces in TypeScript: IUser vs User

In TypeScript, it is common for developers to prefix their interfaces with "I" (e.g., IUser) following the Hungarian notation. However, not all developers adhere to this convention.

I used to prefer using the "I" prefix for my interfaces as I believed it improved the reliability and clarity of my code. I also extended this convention to types, like TUser.

However, I encountered an issue when I needed to convert some interfaces into types, specifically when my interface became a union type of other interfaces. This necessitated replacing all the "I" prefixes with "T" throughout the codebase. These changes proved to be cumbersome, unnecessary. This issue has occurred multiple times for me and my colleagues, leading us to abandon the use of the "I" prefix.

I would like to know your thoughts on this matter. Do you also use prefixes for your interfaces?

💖 💪 🙅 🚩
mpotapov
Mikhail Potapov

Posted on May 17, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related