Default attributes warning

This commit is contained in:
barsdeveloper
2022-05-01 12:54:55 +02:00
parent fcf1bbf32c
commit 2617e15691
5 changed files with 51 additions and 26 deletions

View File

@@ -19,11 +19,17 @@ export default class IEntity {
Object.getOwnPropertyNames(properties),
Object.getOwnPropertyNames(values ?? {})
)) {
if (!(property in properties)) {
console.warn(`Property ${prefix}${property} is not defined in ${this.constructor.name}`)
}
let defaultValue = properties[property]
const defaultType = Utility.getType(defaultValue)
if (!(property in properties)) {
console.warn(`Property ${prefix}${property} is not defined in ${this.constructor.name}`)
} else if (
defaultValue != null
&& !(defaultValue instanceof TypeInitialization && !defaultValue.showDefault)
&& !(property in values)
) {
console.warn(`${this.constructor.name} adds property ${prefix}${property} not defined in the serialized data`)
}
// Not instanceof because all objects are instenceof Object, exact match needed
if (defaultType === Object) {
target[property] = {}

View File

@@ -15,6 +15,11 @@ export default class KeyBindingEntity extends IEntity {
}
constructor(options = {}) {
options.ActionName = options.ActionName ?? ""
options.bShift = options.bShift ?? false
options.bCtrl = options.bCtrl ?? false
options.bAlt = options.bAlt ?? false
options.bCmd = options.bCmd ?? false
super(options)
/** @type {String} */ this.ActionName
/** @type {Boolean} */ this.bShift

View File

@@ -27,10 +27,11 @@ export default class PinEntity extends IEntity {
bIsConst: false,
bIsWeakPointer: false,
bIsUObjectWrapper: false,
bSerializeAsSinglePrecisionFloat: false,
},
LinkedTo: new TypeInitialization([PinReferenceEntity], false),
DefaultValue: new TypeInitialization(String, false),
AutogeneratedDefaultValue: "",
AutogeneratedDefaultValue: new TypeInitialization(String, false),
DefaultObject: new TypeInitialization(ObjectReferenceEntity, false, null),
PersistentGuid: GuidEntity,
bHidden: false,