Fix Function reference

This commit is contained in:
barsdeveloper
2024-06-05 15:58:55 +02:00
parent ad8305ca52
commit beccfe522a
10 changed files with 227 additions and 298 deletions

View File

@@ -7,7 +7,7 @@ export default class IEntity {
/** @type {(v: String) => String} */
static same = v => v
/** @type {(entity: Attribute, serialized: String) => String} */
/** @type {(entity: IEntity, serialized: String) => String} */
static notWrapped = (entity, serialized) => serialized
/** @type {(entity: IEntity, serialized: String) => String} */
@@ -92,21 +92,6 @@ export default class IEntity {
return self.name
}
/** @param {String} key */
showProperty(key) {
/** @type {IEntity} */
let value = this[key]
const Self = this.Self()
if (Self.silent && Self.default !== undefined) {
if (Self["#default"] === undefined) {
Self["#default"] = Self.default(Self)
}
const defaultValue = Self["#default"]
return !value.equals(defaultValue)
}
return true
}
/**
* @protected
* @template {typeof IEntity} T
@@ -115,6 +100,7 @@ export default class IEntity {
*/
static asUniqueClass() {
if (this.name.length) {
// @ts-expect-error
return class extends this { }
}
return this
@@ -199,6 +185,21 @@ export default class IEntity {
return /** @type {T} */(this.constructor)
}
/** @param {String} key */
showProperty(key) {
/** @type {IEntity} */
let value = this[key]
const Self = this.Self()
if (Self.silent && Self.default !== undefined) {
if (Self["#default"] === undefined) {
Self["#default"] = Self.default(Self)
}
const defaultValue = Self["#default"]
return !value.equals(defaultValue)
}
return true
}
/**
*
* @param {String} attribute
@@ -316,6 +317,6 @@ export default class IEntity {
if (this instanceof IEntity && this.trailing && result.length) {
result += Self.attributeSeparator
}
return wrap(this, result)
return wrap(/** @type {IEntity} */(this), result)
}
}