chore: properly infer return type from model config (#8079)
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
|||||||
Context,
|
Context,
|
||||||
FindConfig,
|
FindConfig,
|
||||||
IDmlEntity,
|
IDmlEntity,
|
||||||
|
InferEntityType,
|
||||||
Pluralize,
|
Pluralize,
|
||||||
RestoreReturn,
|
RestoreReturn,
|
||||||
SoftDeleteReturn,
|
SoftDeleteReturn,
|
||||||
@@ -40,7 +41,11 @@ export type ModelsConfigTemplate = { [key: string]: ModelDTOConfig }
|
|||||||
|
|
||||||
export type ModelConfigurationsToConfigTemplate<T extends ModelEntries> = {
|
export type ModelConfigurationsToConfigTemplate<T extends ModelEntries> = {
|
||||||
[Key in keyof T]: {
|
[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 { model: infer MODEL }
|
||||||
? MODEL
|
? MODEL
|
||||||
: T[Key] extends IDmlEntity<any, any>
|
: T[Key] extends IDmlEntity<any, any>
|
||||||
|
|||||||
Reference in New Issue
Block a user