Type names should accurately describe the purpose and content of the type. For instance, in this example the type should clearly mention it refers to the react component types, and at the same time also define for which react component the type is for.
Avoid I and T 🙅🏻♂️
Avoid prefixes like I and T you might have seen some codebase writing their type names with I or T prefix, denoting that they are interfaces or types respectively, but actually if you think more deeply they don’t add any values at all, moreover it looks ugly to me personally. Also, think of a case when you change it from a type to an interface, would you be going to each instances and renaming it. I would suggest just avoid these prefixes.
Generic Type Params 🥋
Just naming your generic type params as
U can be very confusing, you might have seen people following conventions for naming their generic type params like T, U, V etc. it is as similar to just naming your function arguments as
arg3 - you can’t take out enough values out of it.
Don’t Pluralize 🎾
Many times, we declare types referring to a bunch of values, like fruits or something, but actually the type is not resembling multiple values, but a value out of them, let’s see from an example -
Until next time 👋🏽