chore(gemini.md): Make the checkExhaustive helper section more brief/direct (#6181)

This commit is contained in:
Richie Foreman 2025-08-13 18:59:46 -04:00 committed by GitHub
parent d6f74ea2f0
commit 514e883af1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 16 deletions

View File

@ -117,25 +117,12 @@ TypeScript's power lies in its ability to provide static type checking, catching
### Type narrowing `switch` clauses ### Type narrowing `switch` clauses
When authoring a switch clause over an enumeration or fixed list of items, Use the `checkExhaustive` helper in the default clause of a switch statement.
always prefer to use the `checkExhaustive` helper method within the default This will ensure that all of the possible options within the value or
clause of the switch. This will ensure that all of the possible options within enumeration are used.
the value or enumeration are used.
This helper method can be found in `packages/cli/src/utils/checks.ts` This helper method can be found in `packages/cli/src/utils/checks.ts`
Here's an example of using the helper method properly:
```
switch (someValue) {
case 1:
case 2:
// ...
default:
return checkExhaustive(someValue);
}
```
### Embracing JavaScript's Array Operators ### Embracing JavaScript's Array Operators
To further enhance code cleanliness and promote safe functional programming practices, leverage JavaScript's rich set of array operators as much as possible. Methods like `.map()`, `.filter()`, `.reduce()`, `.slice()`, `.sort()`, and others are incredibly powerful for transforming and manipulating data collections in an immutable and declarative way. To further enhance code cleanliness and promote safe functional programming practices, leverage JavaScript's rich set of array operators as much as possible. Methods like `.map()`, `.filter()`, `.reduce()`, `.slice()`, `.sort()`, and others are incredibly powerful for transforming and manipulating data collections in an immutable and declarative way.