Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing filter overload to allow for type narrowing #149

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

kitten
Copy link
Member

@kitten kitten commented Mar 10, 2023

Resolves #148

This adds a missing overload for filter which will allow us to narrow types, e.g. by applying type conditions. We can now specify narrowing types and still get the desired output without casting:

pipe(
  fromArray([false, true, false, true]),
  filter((x): x is true => !!x),
  forEach(console.log), // always true
);

@kitten kitten force-pushed the feat/add-filter-output-type branch from d87953e to 3cc8a5d Compare March 10, 2023 18:57
@kitten kitten merged commit 6111f95 into main Mar 10, 2023
@kitten kitten deleted the feat/add-filter-output-type branch March 10, 2023 19:18
@github-actions github-actions bot mentioned this pull request Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Narrowing overload for filter
2 participants