-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
TypeScript type for EntityDTO with ManyToOne
field is not correct
#2414
Comments
It can be PK or an object, depending of if you populate it. This information is available on the Don't expec too much magic, those types will be always a bit wonky as we don't have the full context in many places. But in this particular example I hope we can handle it. edit: Actually this might be problematic too, as I don't see a way to make the |
This will be finally resolved with the TS 4.8 update, including the inference for base entity methods. It will be slightly breaking (on type level) release for those who define custom |
Describe the bug
When JSONify entities which has unpopulated ManyToOne fields, the return result has wrong TypeScript types.
Stack trace
To Reproduce
Steps to reproduce the behavior:
teamMemberJSON.team
's type now should beEntityDTO<Team>
, but actually, it's a string id. So it causes some type errorsExpected behavior
Either set unpopulatd ManyToOne fields of JSONified object to string, or something like
team: { id: '{actual-id}' }
;Additional context
Versions
The text was updated successfully, but these errors were encountered: