Open outerlook opened 2 years ago
As someone that uses "WebSite" for the main type but still want access to types from LocalBusiness such as "telephone" and "email", this is MUCH needed for me.
Thank you.
Quick question: How would you expect this to operate, e.g., if you have:
const businessSite: MultiTyped<[WebSite, LocalBusiness]> = {
// ...
};
would you expect that "@type"
:
["WebSite", "LocalBusiness"]
and ["LocalBusiness", "WebSite"]
? (that might be hard ish)["WebSite", "LocalBusiness"]
, or any sub-type of WebSite and any sub-type of LocalBusiness?Hm, I never actually thought of that. I personally use additionalType
, meaning that WebSite would still remain the main, while having any additional type that LocalBusiness has to offer.
Alternatively, maybe I'm just doing schema things wrong and there's a better way to do this. I wish I knew who to contact about this.
@Eyas Without getting into too much details, as user, between both I expect the 2nd option. Tuple on generics, same on array and subtypes
Jumping in to say I'd also love to see support for this.
https://json-ld.org/spec/latest/json-ld/#example-14-specifying-multiple-types-for-a-node
Hey @JacobGrady -- In your use cases, would combining the two "leaf" types be acceptable? i.e. the examples give "Restaurant + Brewery" and then uses them as such.
Is there ever a case where you might havea "super-type" in your multi-typed entity?
Eg.
function something(entity: MultiTyped<[FoodEstablishment, EntertainmentBusiness]>) { ...}
something({
"@type": ["FoodEstablishment", "EntertainmentBusiness"], // works
...
})
something({
"@type": ["Brewery", "ComedyClub"], // also works
...
})
The reason I asked is that the second is pretty hard and I haven't figured out a way to support that yet.
Thanks for the fast reply @Eyas! We are looking to combine unique properties from multiple types, something like this:
something({
"@context": "https://schema.org",
"@type": ["Product", "Book"],
"name": "The Catcher in the Rye",
"author": {
"@type": "Person",
"name": "J.D. Salinger"
},
"brand": {
"@type": "Brand",
"name": "Old School Books"
},
"offers": {
"@type": "AggregateOffer",
"offerCount": "5",
"lowPrice": "19.99",
"highPrice": "99.99",
"priceCurrency": "USD"
}
}
)
In this example it's "author" and "brand", but there are other properties like those. It's entirely possible we are doing this wrong/there is a better way to achieve the same thing. Here's the above passing the rich results test.
I did just notice on those Google docs:
Google doesn't show a rich result for Software Apps that only have the [VideoGame] type. To make sure that your Software App is eligible for display as a rich result, co-type the [VideoGame] type with another type. For example:
{
"@context": "https://schema.org",
"@type": ["VideoGame", "MobileApplication"],
....
}
So at least in that example, Google is requiring a second more specific type?
So at least in that example, Google is requiring a second more specific type?
I'm not sure... I think the SEO folks might have a better answer and reaching out to their support forums directly might be your best bet.
We are looking to combine unique properties from multiple types, something like this:
Yep, I totally agree. But what I'm wondering is what kind of support to sub-types you need.
E.g. if you had a function that expected (Product, Book), are you okay if it only accepted Product and Book types, and not their sub-types?
E.g. if you had a function that expected (Product, Book), are you okay if it only accepted Product and Book types, and not their sub-types?
100% totally okay with that, I think it's preferred tbh. We would probably want to add the relevant sub-types into that @type array if we had any.
Not sure if helpful, but here's another example from those Google docs: https://developers.google.com/search/docs/advanced/structured-data/product#product-properties
Hi! I don't know if I missed something, but it appears not to support Multi-Typed Entities. Is it some typescript limitation?
Thanks in advance!