You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/src/pages/index.mdx
+15-5Lines changed: 15 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -945,10 +945,14 @@ Pascal case
945
945
946
946
#### Generics
947
947
948
-
A generic variable must start with the capital letter T followed by a descriptive name `TRequest`, `TFooBar`.
948
+
A generic type parameter must start with the capital letter T followed by a descriptive name `TRequest`, `TFooBar`.
949
949
950
-
Creating more complex types often include generics, which can make them hard to read and understand, that's why we try to put best effort when naming them.
951
-
Naming generics using popular convention with one letter `T`, `K` etc. is not allowed, the more variables we introduce, the easier it is to mistake them.
950
+
Key reasons and benefits:
951
+
952
+
- Complex types often involve generics, where clear naming improves readability and maintainability.
953
+
- Single letter generics like `T`, `K`, `U` are disallowed, the more parameters we introduce, the easier it is to mistake them.
954
+
- Prefixing with `T` makes it immediately obvious that it's a generic type parameter, not a regular type.
955
+
- A common scenario is when a generic parameter shadows an existing type due to having the same name e.g. `<RequestextendsRequest>`
0 commit comments