diff --git a/packages/core/types/src/common/common.ts b/packages/core/types/src/common/common.ts index 1697c4f5c4..ce710376fe 100644 --- a/packages/core/types/src/common/common.ts +++ b/packages/core/types/src/common/common.ts @@ -10,6 +10,13 @@ import { import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder" import { FindOptionsRelations } from "typeorm/find-options/FindOptionsRelations" +/** + * Prettify complex types to a flat object structure + */ +export type Prettify = { + [K in keyof T]: T[K] +} & {} + /** * Utility type used to remove some optional attributes (coming from K) from a type T */ diff --git a/packages/core/types/src/dml/index.ts b/packages/core/types/src/dml/index.ts index 321de7b1fc..b5ebbcaf73 100644 --- a/packages/core/types/src/dml/index.ts +++ b/packages/core/types/src/dml/index.ts @@ -1,4 +1,4 @@ -import { CamelCase } from "../common" +import { CamelCase, Prettify } from "../common" /** * Symbol to identify a DML entity from an object @@ -187,7 +187,7 @@ export type InferManyToManyFields = InferHasManyFields * Inferring the types of the schema fields from the DML * entity */ -export type InferSchemaFields = { +export type InferSchemaFields = Prettify<{ [K in keyof Schema]: Schema[K] extends RelationshipType ? Schema[K]["type"] extends "belongsTo" ? InferBelongsToFields @@ -199,7 +199,7 @@ export type InferSchemaFields = { ? InferManyToManyFields : never : Schema[K]["$dataType"] -} +}> /** * Helper to infer the schema type of a DmlEntity