JsDoc types fixed and typecheck activated

This commit is contained in:
barsdeveloper
2022-03-30 21:59:41 +02:00
parent 464a9c068d
commit 90400110e2
33 changed files with 391 additions and 151 deletions

View File

@@ -9,4 +9,10 @@ export default class FunctionReferenceEntity extends IEntity {
MemberParent: ObjectReferenceEntity,
MemberName: "",
}
constructor(options = {}) {
super(options)
/** @type {ObjectReferenceEntity} */ this.MemberParent
/** @type {String} */ this.MemberName
}
}

View File

@@ -20,6 +20,11 @@ export default class GuidEntity extends IEntity {
return new GuidEntity({ value: guid })
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.value
}
valueOf() {
return this.value
}

View File

@@ -5,6 +5,8 @@ import Utility from "../Utility"
export default class IEntity {
static attributes = {}
constructor(options = {}) {
/**
* @param {String[]} prefix
@@ -52,6 +54,11 @@ export default class IEntity {
target[property] = TypeInitialization.sanitize(defaultValue)
}
}
// @ts-expect-error
defineAllAttributes([], this, this.constructor.attributes)
}
empty() {
return true
}
}

View File

@@ -16,6 +16,7 @@ export default class IdentifierEntity extends IEntity {
}
}
super(options)
/** @type {String} */ this.value
}
valueOf() {

View File

@@ -8,7 +8,10 @@ export default class IntegerEntity extends IEntity {
value: Number,
}
constructor(options = {}) {
/**
* @param {Object | Number | String} options
*/
constructor(options = 0) {
if (options.constructor == Number || options.constructor == String) {
options = {
value: options,

View File

@@ -13,7 +13,14 @@ export default class KeyBindingEntity extends IEntity {
bCmd: false,
Key: IdentifierEntity,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.ActionName
/** @type {Boolean} */ this.bShift
/** @type {Boolean} */ this.bCtrl
/** @type {Boolean} */ this.bAlt
/** @type {Boolean} */ this.bCmd
/** @type {IdentifierEntity} */ this.Key
}
}

View File

@@ -10,4 +10,11 @@ export default class LocalizedTextEntity extends IEntity {
key: String,
value: String,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.namespace
/** @type {String} */ this.key
/** @type {String} */ this.value
}
}

View File

@@ -29,6 +29,24 @@ export default class ObjectEntity extends IEntity {
CustomProperties: [PinEntity],
}
constructor(options = {}) {
super(options)
/** @type {ObjectReferenceEntity} */ this.Class
/** @type {String} */ this.Name
/** @type {Boolean} */ this.bIsPureFunc
/** @type {VariableReferenceEntity} */ this.VariableReference
/** @type {FunctionReferenceEntity} */ this.FunctionReference
/** @type {FunctionReferenceEntity} */ this.EventReference
/** @type {ObjectReferenceEntity} */ this.TargetType
/** @type {IntegerEntity} */ this.NodePosX
/** @type {IntegerEntity} */ this.NodePosY
/** @type {IdentifierEntity} */ this.AdvancedPinDisplay
/** @type {GuidEntity} */ this.NodeGuid
/** @type {IntegerEntity} */ this.ErrorType
/** @type {String} */ this.ErrorMsg
/** @type {PinEntity[]} */ this.CustomProperties
}
/**
* @returns {String}
*/

View File

@@ -8,4 +8,14 @@ export default class ObjectReferenceEntity extends IEntity {
type: String,
path: String,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.type
/** @type {String} */ this.path
}
empty() {
return false
}
}

View File

@@ -8,6 +8,15 @@ export default class PathSymbolEntity extends IEntity {
value: String,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.value
}
valueOf() {
return this.value
}
toString() {
return this.value
}

View File

@@ -7,20 +7,6 @@ import ObjectReferenceEntity from "./ObjectReferenceEntity"
import PinReferenceEntity from "./PinReferenceEntity"
import TypeInitialization from "./TypeInitialization"
/**
* @typedef {{
* PinCategory: String,
* PinSubCategory: String,
* PinSubCategoryObject: ObjectReferenceEntity,
* PinSubCategoryMemberReference: *,
* PinValueType: String,
* ContainerType: ObjectReferenceEntity,
* bIsReference: Boolean,
* bIsConst: Boolean,
* bIsWeakPointer: Boolean,
* bIsUObjectWrapper: Boolean,
* }} PinTypeObjectType
*/
export default class PinEntity extends IEntity {
static lookbehind = "Pin"
@@ -55,6 +41,40 @@ export default class PinEntity extends IEntity {
bOrphanedPin: false,
}
constructor(options = {}) {
super(options)
/** @type {GuidEntity} */ this.PinId
/** @type {String} */ this.PinName
/** @type {LocalizedTextEntity} */ this.PinFriendlyName
/** @type {String} */ this.PinToolTip
/** @type {String} */ this.Direction
/**
* @type {{
* PinCategory: String,
* PinSubCategory: String,
* PinSubCategoryObject: ObjectReferenceEntity,
* PinSubCategoryMemberReference: any,
* PinValueType: String,
* ContainerType: ObjectReferenceEntity,
* bIsReference: Boolean,
* bIsConst: Boolean,
* bIsWeakPointer: Boolean,
* bIsUObjectWrapper: Boolean,
* }}
*/ this.PinType
/** @type {PinReferenceEntity[]} */ this.LinkedTo
/** @type {String} */ this.DefaultValue
/** @type {String} */ this.AutogeneratedDefaultValue
/** @type {ObjectReferenceEntity} */ this.DefaultObject
/** @type {GuidEntity} */ this.PersistentGuid
/** @type {Boolean} */ this.bHidden
/** @type {Boolean} */ this.bNotConnectable
/** @type {Boolean} */ this.bDefaultValueIsReadOnly
/** @type {Boolean} */ this.bDefaultValueIsIgnored
/** @type {Boolean} */ this.bAdvancedView
/** @type {Boolean} */ this.bOrphanedPin
}
isInput() {
return !this.bHidden && this.Direction !== "EGPD_Output"
}
@@ -75,6 +95,7 @@ export default class PinEntity extends IEntity {
/** @type {PinReferenceEntity[]} */
this.LinkedTo
const linkFound = this.LinkedTo?.find(pinReferenceEntity => {
// @ts-ignore
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
})
@@ -96,6 +117,7 @@ export default class PinEntity extends IEntity {
/** @type {PinReferenceEntity[]} */
this.LinkedTo
const indexElement = this.LinkedTo.findIndex(pinReferenceEntity => {
// @ts-expect-error
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid == targetPinEntity.PinId
})

View File

@@ -10,4 +10,10 @@ export default class PinReferenceEntity extends IEntity {
objectName: PathSymbolEntity,
pinGuid: GuidEntity,
}
constructor(options = {}) {
super(options)
/** @type {PathSymbolEntity} */ this.objectName
/** @type {GuidEntity} */ this.pinGuid
}
}

View File

@@ -1,5 +1,8 @@
// @ts-check
/**
* @template T
*/
export default class TypeInitialization {
static sanitize(value) {
@@ -13,9 +16,9 @@ export default class TypeInitialization {
}
/**
* @param {Object} type
* @param {boolean} showDefault
* @param {*} value
* @param {new () => T} type
* @param {Boolean} showDefault
* @param {any} value
*/
constructor(type, showDefault = true, value = undefined) {
if (value === undefined) {

View File

@@ -10,4 +10,11 @@ export default class VariableReferenceEntity extends IEntity {
MemberGuid: GuidEntity,
bSelfContext: false,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.MemberName
/** @type {GuidEntity} */ this.MemberGuid
/** @type {Boolean} */ this.bSelfContext
}
}