Slice.primary.link type

Hi! I'm currently trying the slicemachine specifically following this guide -> Create Navigation Menus with Next.js - Documentation - Prismic and i'm having some trouble with the types definition.

After creating the navigation slice and the navigation items i'm trying to access to the uid property of the Link field but it seems that the only available field is slice.primary.link.link_type but not slice.primary.link.uid (they're available on the response but not in the type definition).

I've also added ./.slicemachine/prismicio.d.ts in my tsconfig.json but still no luck; is there any way to add proper types?

Thanks!

Hello Emiliano,

Welcome to the Prismic community, and thanks for reaching out to us.

The fields in a slice you can access come under the data property, and the UID comes under results, so you can not access the UID field. I would like to know more about your use case. Why do you want to access the UID field while creating navigation?

I am looking forward to hearing from you back.

Thanks,
Priyanka

Hi, and thanks for the answer! Maybe i didn't explain myself well:

As you can see here in the response, i have the link item, so i can get the uid like this:
item.primary.link.uid

but for some reason the type only allows to select the link_type property

Same thing happen for the Media link;

As you can see from the screen, the api returns an object containing multiple properties, but types only target link_type.

I guess in this case the right thing to do do is to use a function to narrow the type, right?

Hello @emiliano.bucci

Sorry for being delayed reply. That's true that You can access metadata under the link field except for link_type. That's the expected behavior.

Thanks,
Priyanka