google / schema-dts

JSON-LD TypeScript types for Schema.org vocabulary
Apache License 2.0
922 stars 35 forks source link

hiringOrganization #165

Closed jared-christensen closed 3 years ago

jared-christensen commented 3 years ago

hiringOrganization seems to be missing name and other properties.

https://developers.google.com/search/docs/advanced/structured-data/job-posting#hiring

Property 'name' does not exist on type 'SchemaValue<Organization | IdReference>'. Property 'name' does not exist on type 'string'.ts(2339)

Eyas commented 3 years ago

This seems to work just fine for me:

import {WithContext, JobPosting} from "schema-dts";

const posting: WithContext<JobPosting> = {
  "@type": "JobPosting",
  "@context": "https://schema.org",
  "hiringOrganization": {
    "@type": "Corporation",
    "name": "foo",
  }
};

https://stackblitz.com/edit/typescript-rlhvuf

The TypeScript error is uninformative, but it could be because you don't have "@type" on the hiringOrganization object you just created.

jared-christensen commented 3 years ago

I'm not sure what I had wrong but it's working now. Thanks for creating these, it's very nice to have types for these!

Eyas commented 3 years ago

Great to know! And you're welcome :)