A few examples from my generated types
image?: (number | null) | Image;
thumbnail?: (number | null) | Image;
youtube_channel: {
link: string;
name: string;
image?: (number | null) | Image;
};
logo?: (number | null) | Image;
This makes my typescript code worse, not a real problem but I was wondering if it's intentional
100% intentional! That's because the data can be different depending on the depth.
If you query your document with depth=0, then image will be a
number(the id of the image).
If you query it with depth=1, then image will be the populated image document (
Image)
And if it doesn't exist it will be
nullor undefined (
?)
So with
?: (number | null) | Imageyou actually have the perfect type which covers all possibilities!
hmmm this makes a lot of sense. Thank you.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.