From 86c45ebd5f0d124d71431e361ef8521ce90369fe Mon Sep 17 00:00:00 2001 From: Chris Kalmar Date: Sat, 30 Jan 2021 15:22:42 +0100 Subject: [PATCH] move data type builder for object types to object notation --- src/engine/datatype/ObjectDataType.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/engine/datatype/ObjectDataType.ts b/src/engine/datatype/ObjectDataType.ts index bb003de4..87027136 100644 --- a/src/engine/datatype/ObjectDataType.ts +++ b/src/engine/datatype/ObjectDataType.ts @@ -1,6 +1,6 @@ import { passOrThrow, resolveFunctionMap, isMap, isFunction } from '../util'; import { isEntity } from '../entity/Entity'; -import { isDataType } from './DataType'; +import { DataTypeFunction, isDataType } from './DataType'; import { ComplexDataType, isComplexDataType } from './ComplexDataType'; import { AttributesMap, @@ -63,10 +63,12 @@ export class ObjectDataType extends ComplexDataType { attributeName: string, ): AttributeBase { if (isFunction(rawAttribute.type)) { - const rawAttributeTypeFn = rawAttribute.type as Function; + const rawAttributeTypeFn = rawAttribute.type; rawAttribute.type = rawAttributeTypeFn({ - name: attributeName, - description: rawAttribute.description, + setup: { + name: attributeName, + description: rawAttribute.description, + }, }); } @@ -169,14 +171,8 @@ export const isObjectDataType = (obj: unknown): obj is ObjectDataType => { export const buildObjectDataType = (obj: { attributes: AttributesSetupMap | AttributesMapGenerator; -}) => { - return ({ - name, - description, - }: { - name: string; - description: string; - }): ObjectDataType => +}): DataTypeFunction => { + return ({ setup: { name, description } }): ObjectDataType => new ObjectDataType({ description, attributes: obj.attributes,