forked from Effect-TS/effect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional analogue of
satisfies
operator (Effect-TS#2080)
Co-authored-by: maksim.khramtsov <maksim.khramtsov@btsdigital.kz> Co-authored-by: Michael Arnaldi <michael.arnaldi@effectful.co>
- Loading branch information
1 parent
dbff62c
commit 11be07b
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
"effect": patch | ||
--- | ||
|
||
Add functional analogue of `satisfies` operator. | ||
This is a convenient operator to use in the `pipe` chain to localize type errors closer to their source. | ||
|
||
```ts | ||
import { satisfies } from "effect/Function" | ||
|
||
const test1 = satisfies<number>()(5 as const) | ||
// ^? const test: 5 | ||
|
||
// @ts-expect-error | ||
const test2 = satisfies<string>()(5) | ||
// ^? Argument of type 'number' is not assignable to parameter of type 'string' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ build/ | |
docs/ | ||
scratchpad/ | ||
.direnv/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters