Skip to content

Array filter/map predicate not type checking properly #12498

Closed
@OliverJAsh

Description

@OliverJAsh

TS 2.0.3

See the comments and last line in the code below for expected/actual.

{
    type Foo = { foo: true };
    const isFoo = (foo: Foo) => foo.foo;

    const xs = [{ foo: true }, undefined];

    isFoo(xs[1]) // good, errors
    const x = undefined as Foo | undefined;
    isFoo(x) // good, errors
    xs.filter(isFoo) // bad, didn't fail, expected filter arg to fail, should be Foo | undefined
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions