Skip to content
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

fix typings for PartialModelGraph and nullable fields #2404

Merged
merged 2 commits into from
Jun 29, 2023

Conversation

falkenhawk
Copy link
Contributor

@falkenhawk falkenhawk commented Apr 22, 2023

ported from ovos#16 and adjusted for a typescript perf workaround which landed in 2cefc77

Handle | null unions properly. (e.g. for nullable BelongsToOneRelations).

Before PartialModelGraph was converting field: Model | null; to field?: Expression<Model | null>, and typescript throws errors for graphs with partial sub-graphs for those nullable relations. (expecting full instance of the model class)
Now it converts it properly to field?: PartialModelGraph<Model> | null 🎉

fixes the issue mentioned in the last paragraph of the #1774 (comment) by @jeremy-w

Handle `| null` unions properly. (e.g. for nullable `BelongsToOneRelations`).

Before `PartialModelGraph` was converting `field: Model | null;` to `field?: Expression<Model | null>`, and typescript throws errors for graphs with partial sub-graphs for those nullable relations. (expecting full instance of the model class)
Now it converts it properly to `field?: PartialModelGraph<Model> | null` 🎉
@falkenhawk falkenhawk force-pushed the fix-typings-for-graphs-with-nullable-fields branch from 479a03d to 69a172c Compare April 22, 2023 18:03
…d relations

when the type of relation's field is defined as nullable with `| null`.
@lehni
Copy link
Collaborator

lehni commented Jun 29, 2023

LGTM, thanks @falkenhawk !

@lehni lehni merged commit 1062bc3 into Vincit:master Jun 29, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants