Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Match.withReturnType api (#2568)
- Loading branch information
Showing
4 changed files
with
254 additions
and
177 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,18 @@ | ||
--- | ||
"effect": patch | ||
--- | ||
|
||
add Match.withReturnType api | ||
|
||
Which can be used to constrain the return type of a match expression. | ||
|
||
```ts | ||
import { Match } from "effect" | ||
|
||
Match.type<string>().pipe( | ||
Match.withReturnType<string>(), | ||
Match.when("foo", () => "foo"), // valid | ||
Match.when("bar", () => 123), // type error | ||
Match.else(() => "baz") | ||
) | ||
``` |
Oops, something went wrong.