chore: properly infer return type from model config (#8079)

This commit is contained in:
Adrien de Peretti
2024-07-11 10:36:07 +02:00
committed by GitHub
parent adfa1d8574
commit 1789b8e315

View File

@@ -3,6 +3,7 @@ import {
Context,
FindConfig,
IDmlEntity,
InferEntityType,
Pluralize,
RestoreReturn,
SoftDeleteReturn,
@@ -40,7 +41,11 @@ export type ModelsConfigTemplate = { [key: string]: ModelDTOConfig }
export type ModelConfigurationsToConfigTemplate<T extends ModelEntries> = {
[Key in keyof T]: {
dto: T[Key] extends Constructor<any> ? InstanceType<T[Key]> : any
dto: T[Key] extends IDmlEntity<any, any>
? InferEntityType<T[Key]>
: T[Key] extends Constructor<any>
? InstanceType<T[Key]>
: any
model: T[Key] extends { model: infer MODEL }
? MODEL
: T[Key] extends IDmlEntity<any, any>