Skip to content

v4 regression: weird type inference inside of Array.every when using pipe #40217

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

Closed
OliverJAsh opened this issue Aug 24, 2020 · 2 comments
Closed
Labels
Needs Investigation This issue needs a team member to investigate its status.
Milestone

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Aug 24, 2020

TypeScript Version: 4.0.2

Search Terms:

Code

declare function pipeWith<A, B>(a: A, ab: (a: A) => B): B;

interface None {
    readonly _tag: 'None';
}
interface Some<A> {
    readonly _tag: 'Some';
    readonly value: A;
}
type Option<A> = None | Some<A>;

declare const getOrElse: <A>(onNone: () => A) => (ma: Option<A>) => A;

declare const myOption: Option<boolean>;

[].map(() =>
    pipeWith(
        // no error ❌
        myOption,
        getOrElse(() => true),
    ),
);

[].every(() =>
    pipeWith(
        // error! ✅
        myOption,
        getOrElse(() => true),
    ),
);

Expected behavior:

Actual behavior:

Playground Link:

Related Issues:

@j-oliveras
Copy link
Contributor

As a reference, some other issues about Array.every with TS 4: #40157, #40184 (first part).

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Sep 9, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Sep 9, 2020
@jakebailey
Copy link
Member

This works as of 4.7: Playground Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

4 participants