mirror of
https://github.com/lingble/twenty.git
synced 2025-11-01 21:27:58 +00:00
Added enums use case (#1428)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user