Skip to content

Commit 2cefc77

Browse files
committed
Fix typescript performance / infinite recursion issues
Closes #2132
1 parent be419e4 commit 2cefc77

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

typings/objection/index.d.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,17 @@ declare namespace Objection {
223223
/**
224224
* Just like PartialModelObject but this is applied recursively to relations.
225225
*/
226-
type PartialModelGraph<M, T = M & GraphParameters> = {
227-
[K in DataPropertyNames<T>]?: Defined<T[K]> extends Model
228-
? PartialModelGraph<Defined<T[K]>>
229-
: Defined<T[K]> extends Array<infer I>
230-
? I extends Model
231-
? PartialModelGraph<I>[]
232-
: Expression<T[K]>
233-
: Expression<T[K]>;
234-
};
226+
type PartialModelGraph<M, T = M & GraphParameters> = T extends any
227+
? {
228+
[K in DataPropertyNames<T>]?: Defined<T[K]> extends Model
229+
? PartialModelGraph<Defined<T[K]>>
230+
: Defined<T[K]> extends Array<infer I>
231+
? I extends Model
232+
? PartialModelGraph<I>[]
233+
: Expression<T[K]>
234+
: Expression<T[K]>;
235+
}
236+
: never;
235237

236238
/**
237239
* Extracts the property names (excluding relations) of a model class.

0 commit comments

Comments
 (0)