Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97371

VSCode JSDoc - define dynamic property type

$
0
0

I have a class that extends a class from some external code. In my "constructor", I set a field that the parent uses to make an API call and upon completion, the result gets stored in the data property (accessible from my class instance via this.data).

How can I tell VSCode via JSDoc comments what the structure of this.data is? I actually create the data structure that returns from the API call so it is known to me. I have @typedefs in my code but I can't seem to properly tell the class what this.data looks like.

The best I have been able to do that works is like the below:

class a extends b {
    render() {
        const stuff = /** @type {Stuff} */ (this.data).stuff[1].thing;
    }
}

The problem with this approach is that it is only applicable for that particular usage of this.data.


Viewing all articles
Browse latest Browse all 97371

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>