Max Schmitt

October 25 2023

How to fix Sanity Error: Uncaught error - Could not resolve jsonType of undefined. No parent type found

I recently ran into an issue with Sanity where I was getting the following error:

Error: Could not resolve jsonType of undefined. No parent type found

This error occurs when you use annotations for the block type incorrectly.

Your code probably looks something like this:

JAVASCRIPT

// ❌ This doesn't work:
annotations: [
{
title: 'Link',
name: 'link',
type: 'Link',
},
]
// ...

This not valid though. If you look at the TypeScript types for annotations, you will find that they are defined as ArrayOfType<'object' | 'reference'>[].

This means that we can only pass { type: 'object' } or { type: 'reference' } as annotations.

The way to fix the error above is by using an object instead:

JAVASCRIPT

// ✅ This works:
annotations: [
{
type: 'object',
fields: [
{
title: 'Link',
name: 'link',
type: 'Link',
},
],
},
]