Skip to content

Commit

Permalink
docs(readme): minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan7237d committed Dec 19, 2020
1 parent b7a63c0 commit 5fa7052
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ The library also provides a function [`teach`](https://github.com/ivan7237d/anti
## Functions for downcasting
The library provides the following identity functions that cast the argument to a subtype, but unlike the TypeScript's `as`, never make assertions:
The library provides the following identity functions that cast the argument to a subtype, but unlike the TypeScript's `as`, never make type assertions:
- [`asNever`](https://github.com/ivan7237d/antiutils/blob/master/src/internal/types/asNever.ts): an identity function with signature `(value: never) => never ` used to typecheck that a symbol has type `never`. Throws if called. Example: if `a` has type `0 | 1`, you could write `a === 0 ? 'zero' : a === 1 ? 'one' : asNever(a)` to make sure that typecheck will fail if the type of `a` changes to say `0 | 1 | 2`.
- [`asNever`](https://github.com/ivan7237d/antiutils/blob/master/src/internal/types/asNever.ts): an identity function with signature `(value: never) => never ` used to typecheck that a branch is unreachable. For example, if `a` has type `0 | 1`, you could write `a === 0 ? 'zero' : a === 1 ? 'one' : asNever(a)` to make sure that typecheck will fail if the type of `a` changes to say `0 | 1 | 2`. Throws if called.
- [`as`](https://github.com/ivan7237d/antiutils/blob/master/src/internal/types/as.ts): an identity function with signature `<T>(value: T) => T` that can be used to downcast a value to a non-generic type: `as<YourType>(yourValue)`.
Expand Down

0 comments on commit 5fa7052

Please sign in to comment.