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
Person does not inherit correctly from interfaces PersonLeaf -> PersonBase #170
Comments
This could be an issue with narrowing that results in a bad error message. In general, if you don't yet have a |
This is the error I'm getting:
|
I referenced a solution in this pull request. I closed the pull and just published my own fork to npm because I have a deadline, but definitely open to working the issue with you. |
DigitalArsenal/schema-dts-test is a private repo, do you mind sharing access? |
Wow, sorry about that, I literally created it just for this thread. |
Got it. Yeah, this is indeed invalid: const podifyPerson = (person: Person) => {
person.additionalName = "POD";
} because a If you expect There is a request somewhere to export |
That's interesting. I'm not sure in what cases |
I also suppose that one could sub-type it like so to reduce verbosity, at the same time that only makes sense if you are going to extend / modify it in some way:
|
See #37 for more details (and #19), but technically in Schema.org, all objects can be referred to as strings. But only a small subset is frequently used. This is typically seen in nested properties, e.g. "author" and "contentLocation" on, say, an ImageObject, where a stirng is used for a Person/Place. See https://schema.org/ImageObject#eg-0021 for example For the purposes of this library, instead of allowing strings on all objects, we opt to only allow strings on objects where cannonical Schema.org examples show them used as strings. |
I see it. Seems more like an oversight to me, since the Person example uses That is a different topic though, I understand why you made that design decision. Thanks for the explanation. |
Not sure if this is a Typescript, bug or a schema issue, but here goes:
Importing:
import type { Person } from "schema-dts";
Throws the TypeScript error:
Property 'familyName' does not exist on type 'Person'. Property 'familyName' does not exist on type 'string'.
;Clearly it is ignoring the logical 'or' in
export declare type Person = PersonLeaf | Patient | string;
and skipping directly to 'string'. Not sure why.The text was updated successfully, but these errors were encountered: