Skip to content

The open alternative to Salesforce, designed for AI.

Added enums use case (#1428)

Lucas Bordeau2ac32e42c550
diff --git a/docs/docs/developer/frontend/style-guide.mdx b/docs/docs/developer/frontend/style-guide.mdx
index 074e7f6cf86..7de2c6b5b32 100644
--- a/docs/docs/developer/frontend/style-guide.mdx
+++ b/docs/docs/developer/frontend/style-guide.mdx
@@ -135,8 +135,6 @@ type MyType = {
You can see why TypeScript recommend avoiding enums here : https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#enums
-However, GraphQL codegen will generate enums, so you can't avoid them completely, but avoid creating new ones.
-
```tsx
// ❌ Bad, utilizes an enum
enum Color {
@@ -153,6 +151,25 @@ let color = Color.Red;
let color: "red" | "green" | "blue" = "red";
```
+#### GraphQL and internal libs
+
+We recommend using enums that are generated by GraphQL codegen.
+
+We also recommend using an enum when using an internal lib, so the internal lib doesn't have to expose a string literal type that is not related to the internal API.
+
+Example :
+
+```TSX
+const {
+ setHotkeyScopeAndMemorizePreviousScope,
+ goBackToPreviousHotkeyScope,
+} = usePreviousHotkeyScope();
+
+setHotkeyScopeAndMemorizePreviousScope(
+ RelationPickerHotkeyScope.RelationPicker,
+);
+```
+
## Styling
### Use StyledComponents