I have code like this:
type A = {
test: number;
a: number;
}[];
type B = {
test: number;
b: number;
}[];
type C = {
test: number;
c: number;
}[];
export const test = (arg: A | B | C) => {
return arg.find((e: (A | B | C)[number]) => e.test === 1);
// ~~~~
// Error 2349
};
In VSCode the find method is underlined with error:
This expression is not callable.
Each member of the union type '{ <S extends { test: number; a: number; }>(predicate: (this: void, value: { test: number; a: number; }, index: number, obj: { test: number; a: 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)
Why does this happen?