Skip to content

Error when trying to use BreadcrumbList schema. #4

@axelferb

Description

@axelferb

So setting up the structure for my BreadcrumbList i end up with this here:

export function BreadCrumbSchema() {
  return <JsonLd<BreadcrumbList>
    item={{
      "@context": "https://schema.org",
      "@type": "BreadcrumbList",
      "itemListElement": [
       {
        "@type": "ListItem",
        position: 1,
        item:
        {
         "@id": "https://example.com/dresses",
         name: "Dresses"
        }
       },
      ]
     }} />;
}

Yet this produces ts errors when trying to run npm start.

Errormesage

TypeScript error: No overload matches this call.
  Overload 1 of 2, '(props: Readonly<{ item: WithContext<BreadcrumbList>; }>): JsonLd<BreadcrumbList>', gave the following error.
    Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }[]' is not assignable to type 'string | ({ "@type": "FinancialService"; } & ThingBase & { "actionableFeedbackPolicy"?: string | ({ "@type": "CreativeWork"; } & ThingBase & { "about"?: string | ({ "@type": "FinancialService"; } & ... 4 more ... & { ...; }) | ... 797 more ... | undefined; ... 94 more ...; "workTranslation"?: ({ ...; } & ... 1 more ...'.
      Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }[]' is not assignable to type 'Thing[]'.
        Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }' is not assignable to type 'Thing'.
          Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }' is not assignable to type 'HowToTool'.
            Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }' is not assignable to type '{ "@type": "HowToTool"; }'.
              Types of property '"@type"' are incompatible.
                Type 'string' is not assignable to type '"HowToTool"'.
  Overload 2 of 2, '(props: { item: WithContext<BreadcrumbList>; }, context?: any): JsonLd<BreadcrumbList>', gave the following error.
    Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }[]' is not assignable to type 'string | ({ "@type": "FinancialService"; } & ThingBase & { "actionableFeedbackPolicy"?: string | ({ "@type": "CreativeWork"; } & ThingBase & { "about"?: string | ({ "@type": "FinancialService"; } & ... 4 more ... & { ...; }) | ... 797 more ... | undefined; ... 94 more ...; "workTranslation"?: ({ ...; } & ... 1 more ...'.
      Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }[]' is not assignable to type 'Thing[]'.
        Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }' is not assignable to type 'Thing'.
          Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }' is not assignable to type 'HowToTool'.
            Type '{ "@type": string; position: number; item: { "@id": string; name: string; }; }' is not assignable to type '{ "@type": "HowToTool"; }'.
              Types of property '"@type"' are incompatible.
                Type 'string' is not assignable to type '"HowToTool"'.  TS2769

    35 |       "@context": "https://schema.org",
    36 |       "@type": "BreadcrumbList",
  > 37 |       "itemListElement": [
       |       ^
    38 |        {
    39 |         "@type": "ListItem",
    40 |         position: 1,

Any clue what might be causing this? I have been following the guidelines from schema.org and that seems to always error out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions