Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan7237d committed Dec 27, 2022
1 parent de63162 commit 31fd213
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ const translate = (word: "hello" | "goodbye") =>

This typechecks because at the point where `word` is passed to `assertNever`, it has type `never`, but will no longer typecheck if you add a third option to `"hello" | "goodbye"`.

If you use lint rules `@typescript-eslint/no-unnecessary-condition` and `eslint-comments/no-unused-disable`, you can do this instead (no need to pass an argument to `assertNever` since `eslint-comments/no-unused-disable` will activate if not all options are exhausted):

```ts
const translate = (word: "hello" | "goodbye") =>
word === "hello"
? "bonjour"
: // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
word === "goodbye"
? "au revoir"
: assertNever();
```

---

[Contributing guidelines](https://github.com/ivan7237d/antiutils/blob/master/.github/CONTRIBUTING.md)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- README for NPM; the one for GitHub is in .github directory. -->

Please refer to the [GitHub README](https://github.com/ivan7237d/antiutils) for full documentation.
Please see the [GitHub README](https://github.com/ivan7237d/antiutils) for full documentation.

0 comments on commit 31fd213

Please sign in to comment.