strapi
strapi copied to clipboard
Defining Type for relations breaks typescript when creating filters
I have the following typescript type:
export type StrapiPage = {
parent?: Strapi4ResponseSingle<StrapiPage>;
localizations?: Strapi4ResponseMany<StrapiPage>;
}
Then, when i try to run a find with the following filter to get all pages without a parent.
return {
parent: {
slug: {
$null: true
}
}
};
the following error occurs:
Object literal may only specify known properties, and 'slug' does not exist in type 'StrapiPrimitiveOperators
If i write it like this, the error is gone, but ofcourse the filters don't work anymore:
return {
parent: {
data: {
attributes: {
slug: {
$null: true
}
}
}
}
};
I understand this is because the return value/structure is different from the filter structure, but i'm not sure how to fix this in my StrapiPage type?