Array filter/map predicate not type checking properly · Issue #12498 · microsoft/TypeScript (original) (raw)
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
}