Hi, I have the following function
import { Content } from '@prismicio/client'
function test(options: Array<Content.BlogCategoryDocument>) {
return options.find(option => option.id === 'easy-test')
}
And this work! But if i Add an Unions Type:
import { Content } from '@prismicio/client'
function test(options: Array<Content.BlogCategoryDocument> | Array<Content.GuideCategoryDocument>) {
return options.find(option => option.id === 'easy-test')
}
Typescript throw me an error on the find()
function
This expression is not callable. Each member of the union type
{ <S extends BlogCategoryDocument>(predicate: (value: BlogCategoryDocument, index: number, obj: BlogCategoryDocument[]) => value is S, thisArg?: any): S; (predicate: (value: BlogCategoryDocument, index: number, obj: BlogCategoryDocument[]) => unknown, thisArg?: any): BlogCategoryDocument; } | { ...; }
has signatures, but none of those signatures are compatible with each other.
Why I cant call find()
? I'm sure that option
has id
in both of case.]
Important: I fetch the data (options param) through client.getByType()
Thank you!