DEV Community

Shin Toshio
Shin Toshio

Posted on

TypeScript Naming Convention

What was a good naming convention for Classes, Interfaces, and Types?

Top comments (5)

Collapse
 
souksyp profile image
Souk Syp. • Edited

Start with “I” (i in uppercase) for interfaces : IEntity, IStore, IFormProps… to distinguish from components name. Just for my eyes.

Collapse
 
ecyrbe profile image
ecyrbe • Edited

I completely disagree.

Prefixing with I will not improve readability and comes from another age of programming where we did not have integrated tools within our IDE to type check our code while writing it.

What is important is to give functionnal meaning to your types.
Here is a more elaborate answer

Collapse
 
pruthvi2103 profile image
Pruthvi Shetty

its pretty objective imo i just like having ISomething so that i can import it across my project and not the variable. since mordern editors and ts has evolved so far, being too concrete just causes confusions in large teams. Just IMO

Collapse
 
souksyp profile image
Souk Syp.

Definitely depends on your taste. I am just too lazy to find names. 🤣

Collapse
 
ecyrbe profile image
ecyrbe • Edited

Here are guideline from typescript team for typescript codebase: github.com/Microsoft/TypeScript/wi...