I am encountering an issue with code that looks like this:
type X = {
test: number;
x: number;
}[];
type Y = {
test: number;
y: number;
}[];
type Z = {
test: number;
z: number;
}[];
export const testFunc = (arg: X | Y | Z) => {
return arg.find((e: (X | Y | Z)[number]) => e.test === 1);
// ~~~~
// Error 2349
};
When using VSCode, the find
method is highlighted with an error message:
This expression is not callable.
Each member of the union type '{ <S extends { test: number; x: number; }>(predicate: (this: void, value: { test: number; x: number; }, index: number, obj: { test: number; x: number; }[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: { ...; }, index: number, obj: { ...; }[]) => unknown, thisArg?: any): { ...; } | undefined; } |...' has signatures, but none of those signatures are compatible with each other. (2349)
What could be causing this issue?