Skip to content

Commit

Permalink
update docusaurus
Browse files Browse the repository at this point in the history
  • Loading branch information
mkosir committed Mar 8, 2024
1 parent c1191fb commit 0a9a969
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions website/src/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ You may encounter discriminated unions under different names such as tagged unio

Embrace using discriminated unions:

- Clear code intent, as it becomes easier to read and understand by explicitly indicating the possible cases for a given type.
- TypeScript can narrow down union types, ensuring code correctness at compile time.
- As mentioned in [Args as Discriminated Union](#args-as-discriminated-union), discriminated union eliminates optional args which decreases complexity on function API.
- Exhaustiveness check - TypeScript can ensure that all possible variants of a type are implemented, eliminating the risk of undefined or unexpected behavior at runtime. ([eslint rule](https://typescript-eslint.io/rules/switch-exhaustiveness-check/))

Expand All @@ -181,6 +179,8 @@ Embrace using discriminated unions:
};
```

- Clear code intent, as it becomes easier to read and understand by explicitly indicating the possible cases for a given type.
- TypeScript can narrow down union types, ensuring code correctness at compile time.
- Discriminated unions make refactoring and maintenance easier by providing a centralized definition of related types. When adding or modifying types within the union, the compiler reports any inconsistencies throughout the codebase.
- IDEs can leverage discriminated unions to provide better autocompletion and type inference.

Expand Down

0 comments on commit 0a9a969

Please sign in to comment.