When fetching the single post using POST_QUERY
from the SANITY package, I encountered an error in TypeScript indicating that the children property does not exist
. Although the TypeScript types show that the children property exists and is accessible, an error is still thrown.
Here is my query:
export const POST_QUERY = defineQuery(`*[_type == "post" && slug.current == $slug][0]`);
const result = await client.fetch(POST_QUERY, { slug: "how-i-became-a-blogger" }) as POST_QUERYResult;
Types: In the full types of my POST_QUERYResult
, you can see that the body contains a children
property.
export type POST_QUERYResult = {
_id: string;
_type: "post";
_createdAt: string;
_updatedAt: string;
// Remaining properties omitted for brevity
} | null;