I need some wrapper classes for converting values from XML to javascript and back. The setup looks like this:
/**
* @template T
* */
class Value {
/**
*
* @param {Element} valueNode
*/
constructor(valueNode) {
this.node = valueNode;
}
/** @type {T} **/
get value() {
return this.node.hasAttribute("value") ? this.convertToJS(this.node.getAttribute("value")) : null;
}
/**
* Must be overriden and provide JS object/variable from the string value
* @param {string} stringValue
* @returns {T}
*/
convertToJS(stringValue) { }
}
/**
* @class
* @extends Value<boolean>
* */
class BoolValue extends Value {
/**
* Must be overriden and provide JS object/variable from the string value
* @param {string} stringValue
* @returns {T}
*/
convertToJS(stringValue) { return stringValue == "true"; }
}
When I have an instance if BoolValue, I'd like visual studio to know that myVar.value is a boolean.
How to tell JSDoc that a class extends a templated class with specific type?
