-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Custom model instances’ type is not assignable to Model
#9405
Comments
the reason for this is that there's basically no way to type Model usefully without a pile of lies. We either have to make all the schema methods completely useless but enable subclasses to satisfy Model, or we have to type Model to understand that its only useful as a subclass at which point if you use it directly you get a lot of If you can come up with a solution that satisfies both things, all for it, but I haven't dreamt one up yet myself and am suspicious that one doesn't exist given how TS does not like subclasses to narrow signatures. |
Reproduction
Example: https://github.com/seanCodes/ember-data-bugs/blob/main/tests/integration/components/info-test.ts#L30
Repo: seanCodes/ember-data-bugs
Description
Custom model instances’ type is not considered to extend
Model
. The types ofModel.eachRelationship()
andModel.eachAttribute()
don’t match, which seems to be caused by the user-defined model expecting stricter values for the first argument of both methods (exact attribute keys, rather than anystring
like the base model).Versions
The text was updated successfully, but these errors were encountered: