Make elements default constructible, testing wip

This commit is contained in:
barsdeveloper
2022-12-24 15:29:12 +01:00
parent 7ed36f21e5
commit c3ab6478b0
53 changed files with 992 additions and 712 deletions

View File

@@ -5,6 +5,7 @@ import TypeInitialization from "./TypeInitialization"
import Utility from "../Utility"
import UnionType from "./UnionType"
/** @typedef {typeof IEntity} EntityConstructor */
/**
* @template {IEntity} T
* @typedef {new (Object) => T} IEntityConstructor
@@ -101,8 +102,7 @@ export default class IEntity extends Observable {
target[attribute] = TypeInitialization.sanitize(defaultValue, defaultType)
}
}
// @ts-expect-error
const attributes = this.constructor.attributes
const attributes = /** @type {typeof IEntity} */(this.constructor).attributes
if (values.constructor !== Object && Object.getOwnPropertyNames(attributes).length === 1) {
// Where there is just one attribute, option can be the value of that attribute
values = {