I'm trying to get syntax highlighting for the properties on my subclasses
class TextField extends Field {
constructor(fieldData) {
super(fieldData);
}
}
...
class Checkbox extends Field {
constructor(fieldData) {
super(fieldData);
}
}
class Field {
constructor(fieldData) {
this.authors = fieldData.authors;// array of strings
this.fieldName = fieldData.fieldName;// string
this.value = fieldData.value;// string or boolean
}
}
When I try creating an instance of TextField and accessing the value property, I want visual studio code to know that the value is a string. However, when I know I have a Textinput, the value property shows me that I have an "any" type.
Is there a way to tell the visual studio code that my TextField instances have values of type string? It usually understands JSDoc, so I've been trying different JSDoc tags. I tried this technique, which did what I wanted, but when I tried creating TextFields, it overrode the values of each property to undefined after calling the super()
class TextField extends Field {
/** @type {string} */
value;
constructor(fieldData) {
super(fieldData);
}
}