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

NonEmptyArray#filter returns wrong type #1388

Closed
pedrodim opened this issue Feb 2, 2021 · 2 comments · Fixed by #1390
Closed

NonEmptyArray#filter returns wrong type #1388

pedrodim opened this issue Feb 2, 2021 · 2 comments · Fixed by #1390
Assignees
Labels

Comments

@pedrodim
Copy link

pedrodim commented Feb 2, 2021

🐛 Bug report

Current Behavior

type Values = "A" | "B";
const values: NonEmptyArray<Values> = ["A", "B"];
const filterValues = (value: Values): value is "B" => value === "B";

const filteredValues = nonEmptyArray.filter(filterValues)(values);

filteredValues is Option<NonEmptyArray<Values>>

Expected behavior

filteredValues is Option<NonEmptyArray<"B">>

Your environment

Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?

Software Version(s)
fp-ts 2.9.3
TypeScript 4.1.3
@samhh
Copy link
Contributor

samhh commented Feb 2, 2021

I can repro:

declare const p: (x: unknown) => x is string;
declare const xs: NonEmptyArray<unknown>;
const ys = NEA.filter(p)(xs);

@gcanti
Copy link
Owner

gcanti commented Feb 2, 2021

@pedrodim @samhh thanks, patch released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants