Typescript error in "orderings" param

Hi there,

I'm using Nuxt 3, and I'm getting a Typescript warning when apply new "orderings" param yo my requests.

As far as I know, orderings was like this:

{
  orderings: '[my.post.date desc]'
}

But now it's an array:

{
  orderings: [
    { field: 'my.post.date', direction: 'desc' }
  ]
}

Well, I'm gettings this warning from Typescript:

Argument of type '{ fetchLinks: string; lang: "es-ES" | "en-EU"; orderings: { field: string; direction: string; }[]; page: number; pageSize: any; filters: any[]; }' is not assignable to parameter of type 'Partial<BuildQueryURLArgs> & FetchParams'.
  Type '{ fetchLinks: string; lang: "es-ES" | "en-EU"; orderings: { field: string; direction: string; }[]; page: number; pageSize: any; filters: any[]; }' is not assignable to type 'Partial<BuildQueryURLArgs>'.
    Types of property 'orderings' are incompatible.
      Type '{ field: string; direction: string; }[]' is not assignable to type 'string | Ordering | (string | Ordering)[] | undefined'.
        Type '{ field: string; direction: string; }[]' is not assignable to type '(string | Ordering)[]'.
          Type '{ field: string; direction: string; }' is not assignable to type 'string | Ordering'.
            Type '{ field: string; direction: string; }' is not assignable to type 'Ordering'.
              Types of property 'direction' are incompatible.
                Type 'string' is not assignable to type '"desc" | "asc" | undefined'.ts-plugin(2345)
const postsParams: {
    fetchLinks: string;
    lang: "es-ES" | "en-EU";
    orderings: {
        field: string;
        direction: string;
    }[];
    page: number;
    pageSize: any;
    filters: any[];
}

Looks like some type is not updated, right?

Thank you.

Hi @cerrutti,

Both orderings methods your share are valid today as of @prismicio/client v7, with the former (string based) being deprecated.

I tried to reproduce your type issue on Nuxt with no luck: Prismic Minimal Example - StackBlitz

According to the snippet you shared (postsParams), if you're abstracting client parameters into a constant, then, you'll need to cast direction ("asc" as const or variable as "asc" | "desc") for TypeScript to stop showing an error. I don't think this is a recent change on our end as direction has been typed like this for a few years now :thinking:

Could you share the versions of nuxt, @nuxtjs/prismic, typescript so we can try to troubleshoot your issue?