You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,7 @@ Type-Level TypeScript takes you on a deep dive into the most advanced features o
101
101
-[`.returnType`](#returntype)
102
102
-[`.exhaustive`](#exhaustive)
103
103
-[`.otherwise`](#otherwise)
104
+
-[`.narrow`](#narrow)
104
105
-[`isMatching`](#ismatching)
105
106
-[Patterns](#patterns)
106
107
-[Literals](#literals)
@@ -640,6 +641,43 @@ returns the result of the pattern-matching expression, or **throws** if no patte
640
641
function run():TOutput;
641
642
```
642
643
644
+
### `.narrow`
645
+
646
+
```ts
647
+
match(...)
648
+
.with(...)
649
+
.narrow()
650
+
.with(...)
651
+
```
652
+
653
+
The `.narrow()` method deeply narrows the input type to exclude all values that have previously been handled. This is useful when you want to exclude cases from union types or nullable properties that are deeply nested.
654
+
655
+
Note that handled case of top-level union types are excluded by default, without calling `.narrow()`.
656
+
657
+
#### Signature
658
+
659
+
```ts
660
+
function narrow():Match<Narrowed<TInput>, TOutput>;
0 commit comments