-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow more primitives (boolean/number/string) #37
Comments
Thanks for the suggestions. This is helpful. For each of these, I'm basically curious if these semantics are seen as "canonical" in general. Any data / leads here will be helpful: For Boolean types, my understanding is that these are expected to be assignable to "https://schema.org/True" and "https://schema.org/False" (from looking at Schema.org examples using Boolean). Do you have an example of true/false JSON primitives being accepted? For Ack on author/contentLocation. I know Person and Place are both accepted the Google Structured Data Testing Tool as stand-ins for |
See the first example here: https://schema.org/isAccessibleForFree
Good point, maybe ignore my suggestion that
That makes sense. I'm fine with that. Another one to consider: allow |
On second thoughts, it seems a shame if the types don't work with the examples provided on https://schema.org/, e.g. https://schema.org/ImageObject uses |
For Booleans, to save backwards compatibility, a good shape would be: enum BooleanEnum {
True = "https://schema.org/True",
False = "https://schema.org/False"
}
/** Boolean: True or False. */
export type Boolean = true | false | BooleanEnum;
export const Boolean = {
True: BooleanEnum.True as const,
False: BooleanEnum.False as const,
} So you can use:
|
Ended up with something slightly different: /** Boolean: True or False. */
export declare type Boolean = true | false | "https://schema.org/True" | "https://schema.org/False";
export declare const Boolean: {
True: "https://schema.org/True" as const;
False: "https://schema.org/False" as const;
}; This also allows users to assign the strings as-is, in addition to |
#47 will fix most of this. Note that, for
won't be fixed. As far as I can tell, SDTT complains if ImageObject is declared a string. Let me know if I'm wrong here. |
@Eyas Thanks for doing that! As for |
Hm. Note that ImageObject doesn't always work as a string, for example: https://lists.w3.org/Archives/Public/public-schemaorg/2019Nov/0003.html Structured Data Testing Tool rejects when "logo" is set to a string, requiring an ImageObject set explicitly. |
E.g. in
ImageObject
:isAccessibleForFree
should be allowed to be aboolean
primitivewidth
andheight
should be allowed to be anumber
primitiveauthor
andcontentLocation
should be allowed to be astring
primitiveRelated: #19
The text was updated successfully, but these errors were encountered: