Following is the code I'm trying to run in a typescript editor
type ABC = {
title: string
}
type DEF = {
name: string
}
type XYZ = {
desc: ABC[] | DEF[]
}
const container: XYZ = {
desc: [{title: 'abc'},{title: 'def'}]
}
const { desc } = container
desc.find((t: ABC) => t.title === 'abc')
But there is red line under find() and when i hover over it I see the following message:
This expression is not callable.Each member of the union type
'{ <S extends ABC>(predicate: (this: void,
value: ABC, index: number, obj: ABC[]) => value is S, thisArg?: any): S |
undefined; (predicate: (value: ABC, index: number, obj: ABC[]) => unknown,
thisArg?: any): ABC | undefined; } | { ...; }' has signatures, but none of
those signatures are compatible with each other.
How do i fix this such that I don't see the squiggly line