Node naming refactoring and additional tests

This commit is contained in:
barsdeveloper
2023-02-07 21:48:34 +01:00
parent 1af1bcaf2c
commit 76df14de95
13 changed files with 403 additions and 155 deletions

View File

@@ -105,15 +105,6 @@ export default class IEntity {
if (defaultValue instanceof Function) {
defaultValue = defaultValue(this)
}
if (defaultType instanceof UnionType) {
if (defaultValue != undefined) {
defaultType = defaultType.types.find(
type => defaultValue instanceof type || defaultValue.constructor == type
) ?? defaultType.getFirstType()
} else {
defaultType = defaultType.getFirstType()
}
}
if (defaultType === undefined) {
defaultType = Utility.getType(defaultValue)
}
@@ -135,7 +126,6 @@ export default class IEntity {
console.warn(
`UEBlueprint: Tried to assign attribute ${prefix}${attributeName} to `
+ `${this.constructor.name} not satisfying the predicate`
)
return
}
@@ -156,6 +146,15 @@ export default class IEntity {
assignAttribute(Utility.sanitize(value, /** @type {AnyValueConstructor<*>} */(defaultType)))
continue // We have a value, need nothing more
}
if (defaultType instanceof UnionType) {
if (defaultValue != undefined) {
defaultType = defaultType.types.find(
type => defaultValue instanceof type || defaultValue.constructor == type
) ?? defaultType.getFirstType()
} else {
defaultType = defaultType.getFirstType()
}
}
if (defaultValue === undefined) {
defaultValue = Utility.sanitize(new /** @type {AnyValueConstructor<*>} */(defaultType)())
}