-
Notifications
You must be signed in to change notification settings - Fork 34
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
ThingBase is not exported #29
Comments
#28 suggested another use-case where something that looks like this. My general concern with exporting intermediate types is just that it ties up future development. Right now the API boundary is just the final types ( As schema-dts matures, I'll be more and more comfortable doing this. Worth looking at this now. I'm curious, though, why not just use export type WithId<T extends Thing> = T & Identified; That's what we do when we define |
But for example |
I wrote up an explanation here about the structure of the type system, but basically, we have something like: declare type ThingBase = {
"additionalType"?: URL | URL[];
"alternateName"?: Text | Text[];
// ...
};
// This is conceptually true but in practice, it is inlined:
export declare type ThingLeaf = {
"@type": "Thing";
} & ThingBase;
export declare type Thing = ThingLeaf | Action | CreativeWork | Event | Intangible | MedicalEntity | Organization | Person | Place | Product /* | ... */; So export declare type Organization = OrganizationLeaf | Airline | Consortium | Corporation | EducationalOrganization | FundingScheme | GovernmentOrganization | LibrarySystem | LocalBusiness | MedicalOrganization | NewsMediaOrganization | NGO | PerformingGroup | Project | SportsOrganization | WorkersUnion; ... and so on. Under the current type system, You can try it out with export declare type WithContext<T extends Thing> = T & {
"@context": "https://schema.org";
}; With that, you can write things like: import { Person, WithContext } from "schema-dts";
const t: WithContext<Person> = {
"@context": "https://schema.org",
"@type": "Person", // "Patient" also works here
"name": "happy"
}; |
While trying to use this library with generics, I find most entities extend
ThingBase
, though it is not exported. I'm trying to extend/enforce our own pattern of use and the lack of export is causing some difficulty.My suggestion would be to simply all created types, and allow the users to determine how they might want to utilize them.
Here's a short use case:
I figured I would file an issue before taking a look at a PR. Thoughts or concerns?
The text was updated successfully, but these errors were encountered: