Slice items typing (next & typescript)

This code will fail because of a typing error:

export type Card = { (listing of props from prismic document)
    icon: string;
    name: AnyRegularField;
    text: AnyRegularField;
    cta_text: AnyRegularField;
    cta_link: FilledLinkToDocumentField<string, string, never> | FilledLinkToWebField;
};
{slice.items.map(({ icon, name, text, cta_text, cta_link }: Card) => (...)))}

On line 9, i am having the error:

Type 'Record<string, AnyRegularField>' is missing the following properties from type 'Card': icon, name, text, cta_text, cta_link

Doing this would fix this error:

{slice.items.map(({ icon, name, text, cta_text, cta_link }: Record<string, AnyRegularField>) => (...)))}

But I don’t want to do this as I would lose the typing of icon for example, which has to be a string in the rest of my code:

<Icon name={icon} ... />

name property of my Icon component has to be of type string (and not AnyRegularField)

How could I solve this issue knowing that I have to type correctly the props that come from my prismic doc?

Hi Louis,

Could you provide more context? Which line is line 9, and where is the definition for Record?

Sam