Skip to content

Commit

Permalink
fix: prevent NoInfer from showing up in display types
Browse files Browse the repository at this point in the history
  • Loading branch information
gvergnaud committed Dec 15, 2024
1 parent 514057f commit e35de42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ export type infer<pattern> = InvertPattern<NoInfer<pattern>, unknown>;
* type Narrowed = P.narrow<Input, typeof Pattern>
* // ^? ['a', 'a' | 'b']
*/
export type narrow<input, pattern extends Pattern<any>> = NoInfer<
ExtractPreciseValue<input, InvertPattern<pattern, input>>
export type narrow<input, pattern extends Pattern<any>> = ExtractPreciseValue<
input,
InvertPattern<pattern, input>
>;

function chainable<pattern extends Matcher<any, any, any, any, any>>(
Expand Down
2 changes: 1 addition & 1 deletion src/types/FindSelected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ export type FindSelected<i, p> =
// This happens if the provided pattern didn't extend Pattern<i>,
// Because the type checker falls back on the general `Pattern<i>` type
// in this case.
NoInfer<Equal<p, Pattern<i>> extends true ? i : Selections<i, p>>;
Equal<p, Pattern<i>> extends true ? i : Selections<i, p>;

0 comments on commit e35de42

Please sign in to comment.