-
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
Cannot 'implement' Person from class #28
Comments
I describe the reasoning briefly here. The quick gist is that we'd like to model super-classes as discriminated unions of their subclasses because:
For what you're trying to do, some ideas:
Generally I'd like not to export too many things, because that increases the API surface area and increases the risk of someone depending on some internal property/implementation that might not always last. So I'd like to understand a bit what your use case is. If this is something compelling and a lot of people might be interested in doing, then exporting |
Thank you for the resource and explanation. Been playing around with Thing, Person and Patient. It kind of makes sense to me now. Was indeed trying to implement Schema.org on the scope of a class since it seems the most optimal way for me to follow Schema.org, hopefully avoid naming conflicts and be able to build on it's conventions & patterns. Might be nice to have a 'schema-dts-leaf' version to seperate and use it for implements. I guess you'd still need methods to export (or import) the data into the class, but at least it can all live at the top level. |
When I try to implement 'Person' on a class like:
TS errors with
Which can be solved by editing this snippet:
to
Obviously, this case is true for any type declaration in the pattern
(...) | [TYPE]
. The same applies to extending interfaces.What is the reason for this pattern? Is it intended?
The text was updated successfully, but these errors were encountered: