GithubHelp home page GithubHelp logo

Comments (8)

Eyas avatar Eyas commented on May 11, 2024 1

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:

  • Boolean.True,
  • Boolean.False,
    as well as true and false.

from schema-dts.

Eyas avatar Eyas commented on May 11, 2024

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 width/height -- these are type Distance of QuantitativeValue. My understanding of both those types is that they're meant to encode a value with some unit attached to it. #19 as you mentioned supported using "string" for these values. I.e. "12 m" (or "13px"). Seems contrary to the intent of the schema to make distance potentially unit-less?

Ack on author/contentLocation. I know Person and Place are both accepted the Google Structured Data Testing Tool as stand-ins for {"@type": ..., "name": <string value> }. My hope was to be slightly opinionated here and allow the equivalent but more verbose version. Does this slow people down in the wild? Curious about your use cases.

from schema-dts.

OliverJAsh avatar OliverJAsh commented on May 11, 2024

Do you have an example of true/false JSON primitives being accepted?

See the first example here: https://schema.org/isAccessibleForFree

image

Seems contrary to the intent of the schema to make distance potentially unit-less?

Good point, maybe ignore my suggestion that number should be allowed!

My hope was to be slightly opinionated here and allow the equivalent but more verbose version. Does this slow people down in the wild? Curious about your use cases.

That makes sense. I'm fine with that.

Another one to consider: allow thumbnail to be a string (URL). Or would you group that with author/contentLocation, i.e. require an object?

from schema-dts.

OliverJAsh avatar OliverJAsh commented on May 11, 2024

My hope was to be slightly opinionated here and allow the equivalent but more verbose version. Does this slow people down in the wild? Curious about your use cases.

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 string for author and contentLocation.

image

from schema-dts.

Eyas avatar Eyas commented on May 11, 2024

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 Boolean.True and Boolean.False.

from schema-dts.

Eyas avatar Eyas commented on May 11, 2024

#47 will fix most of this. Note that, for

Another one to consider: allow thumbnail to be a string (URL). Or would you group that with author/contentLocation, i.e. require an object?

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.

from schema-dts.

OliverJAsh avatar OliverJAsh commented on May 11, 2024

@Eyas Thanks for doing that!

As for thumbnail, here's an example on the official schema website demonstrating thumbnail as a string:

image

https://schema.org/VideoObject

from schema-dts.

Eyas avatar Eyas commented on May 11, 2024

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.

from schema-dts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.