Skip to content

.every() .find() .filter() methods fail with "This expression is not callable." error on union of array types #44373

Closed
@ialexryan

Description

@ialexryan

Bug Report

🔎 Search Terms

  • This expression is not callable
  • none of those signatures are compatible with each other

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about union types. I also reviewed previous related issues.

⏯ Playground Link

💻 Code

interface Fizz {
    id: number;
    fizz: string;
}

interface Buzz {
    id: number;
    buzz: string;
}

([] as Fizz[] | Buzz[]).filter(item => item.id < 5); 

🙁 Actual behavior

Compilation fails with the following error:

This expression is not callable.
  Each member of the union type '{ <S extends Fizz>(predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): Fizz[]; } | { ...; }' has signatures, but none of those signatures are compatible with each other.

🙂 Expected behavior

Compilation succeeds, as it does for map and several other array functions.

🔖 Useful links

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions