File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -222,14 +222,18 @@ declare namespace Objection {
222
222
* Just like PartialModelObject but this is applied recursively to relations.
223
223
*/
224
224
type PartialModelGraph < M , T = M & GraphParameters > = {
225
- [ K in DataPropertyNames < T > ] ?: Defined < T [ K ] > extends Model
226
- ? PartialModelGraph < Defined < T [ K ] > >
227
- : Defined < T [ K ] > extends Array < infer I >
225
+ [ K in DataPropertyNames < T > ] ?: null extends T [ K ]
226
+ ? PartialModelGraphField < NonNullable < T [ K ] > > | null // handle nullable BelongsToOneRelations
227
+ : PartialModelGraphField < T [ K ] > ;
228
+ } ;
229
+
230
+ type PartialModelGraphField < F > = Defined < F > extends Model
231
+ ? PartialModelGraph < Defined < F > >
232
+ : Defined < F > extends Array < infer I >
228
233
? I extends Model
229
234
? PartialModelGraph < I > [ ]
230
- : Expression < T [ K ] >
231
- : Expression < T [ K ] > ;
232
- } ;
235
+ : Expression < F >
236
+ : Expression < F > ;
233
237
234
238
/**
235
239
* Extracts the property names (excluding relations) of a model class.
You can’t perform that action at this time.
0 commit comments