Prettify DML properties when inferred (#7937)
This commit is contained in:
@@ -10,6 +10,13 @@ import {
|
|||||||
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
|
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
|
||||||
import { FindOptionsRelations } from "typeorm/find-options/FindOptionsRelations"
|
import { FindOptionsRelations } from "typeorm/find-options/FindOptionsRelations"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prettify complex types to a flat object structure
|
||||||
|
*/
|
||||||
|
export type Prettify<T> = {
|
||||||
|
[K in keyof T]: T[K]
|
||||||
|
} & {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility type used to remove some optional attributes (coming from K) from a type T
|
* Utility type used to remove some optional attributes (coming from K) from a type T
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CamelCase } from "../common"
|
import { CamelCase, Prettify } from "../common"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Symbol to identify a DML entity from an object
|
* Symbol to identify a DML entity from an object
|
||||||
@@ -187,7 +187,7 @@ export type InferManyToManyFields<Relation> = InferHasManyFields<Relation>
|
|||||||
* Inferring the types of the schema fields from the DML
|
* Inferring the types of the schema fields from the DML
|
||||||
* entity
|
* entity
|
||||||
*/
|
*/
|
||||||
export type InferSchemaFields<Schema extends DMLSchema> = {
|
export type InferSchemaFields<Schema extends DMLSchema> = Prettify<{
|
||||||
[K in keyof Schema]: Schema[K] extends RelationshipType<any>
|
[K in keyof Schema]: Schema[K] extends RelationshipType<any>
|
||||||
? Schema[K]["type"] extends "belongsTo"
|
? Schema[K]["type"] extends "belongsTo"
|
||||||
? InferBelongsToFields<Schema[K]["$dataType"]>
|
? InferBelongsToFields<Schema[K]["$dataType"]>
|
||||||
@@ -199,7 +199,7 @@ export type InferSchemaFields<Schema extends DMLSchema> = {
|
|||||||
? InferManyToManyFields<Schema[K]["$dataType"]>
|
? InferManyToManyFields<Schema[K]["$dataType"]>
|
||||||
: never
|
: never
|
||||||
: Schema[K]["$dataType"]
|
: Schema[K]["$dataType"]
|
||||||
}
|
}>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to infer the schema type of a DmlEntity
|
* Helper to infer the schema type of a DmlEntity
|
||||||
|
|||||||
Reference in New Issue
Block a user