As the following just generates class documentation for SomeClass, but omits the someProperty documentation.Move the JSDoc into the constructor where it is first defined.I'm unsure if there is a way of accomplishing it with the Thanks for contributing an answer to Stack Overflow! Unfortunately, none of them work right now!want to use jsdoc to add optional prop of a class, currently it does't respect optional flag.want to use jsdoc to add optional prop of a class, currently it does't respect optional flag.Is it possible somehow to make this work with ES6 export/imports? The Overflow Blog By clicking “Post Your Answer”, you agree to our To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Suggestion. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.By clicking “Sign up for GitHub”, you agree to our I would like to be able to extend the type of an ES6 class using JSDoc comments, such that TypeScript understands there are other properties that might be added to the object later.Alternatively, I would like a way to indicate that a given class acts as a container that can contain any possible key.I have a class that is used like a DTO. CommonJS modules do indeed require matching module augmentation syntax, but it does not work right now. Here's what I got to work in Typescript:Unfortunately, the same thing doesn't work with commonjs:At this point, I think we have 3 proposals to solve this problem. A way to specify class properties using JSDoc */ const Point = class { // and so on } Extending classes. How to use JSDoc to document an ES6 class property. Let me check...Bad news. Where developers & technologists share private knowledge with coworkersProgramming & related technical career opportunities Fred Stark Fred Stark.

Once the type is defined in source, you can use it as a type for JSDoc tags like @param or @returns that make use of a type.. Syntax: /** * @typedef {Object} Person * @property {number} age Length of time the person has lived * @property {string} name The word by …

Featured on Meta Free 30 Day Trial

Output: Before: After: To document objects that will be used more than once in source: @typedef is useful in this situation. 40.5k 26 26 gold badges 112 112 silver badges 163 163 bronze badges.

JSDoc has @function or @method to define functions or class methods. You do this with the @augments (or @extends) tag. For a function it is enough to indicate its parameters and return type.

Take, for example:TypeScript now recognizes the object type, but whenever I try to use other properties, it complains. I would like to be able to extend the type of an ES6 class using JSDoc comments, such that TypeScript understands there are other properties that might be added to the object later. site design / logo © 2020 Stack Exchange Inc; user contributions licensed under your coworkers to find and share information. JSDoc conflates shared properties and per-instance properties and calls them instance properties. 4,022 22 22 silver badges 35 35 bronze badges. asked Jul 22 '18 at 17:55. balupton balupton. jsdoc es6-class.

When you use the extends keyword to extend an existing class, you also need to tell JSDoc which class you're extending. – Flame_Phoenix Apr 25 '17 at 9:19. It has some properties that are guaranteed to be there, but is also used for a lot of optional properties. share | improve this answer | follow | edited Jul 31 '19 at 23:46. answered Apr 24 '17 at 6:58.