-
Notifications
You must be signed in to change notification settings - Fork 12.8k
JSDoc : add support for @method (and @property) #28730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'll second this. Our use case is a large number of classes of the following form: import { extendObservable } from 'mobx';
class Foo {
constructor() {
extendObservable(this, {
bar: 123,
// ...
});
}
}
class Foo {
/** @type {number} */
bar;
constructor () { /* ... */ }
} |
Is there a current workaround for this? I'm trying to build typings (using function Foo() { ... }
Object.defineProperties(Foo.prototype, {
/**
* @memberof Foo
* @type {number}
*/
bar: { get: function() {...} },
/**
* @memberof Foo
* @type {string}
*/
baz: { get: function() {...} },
}); I'm not at liberty to convert this to a more straightforward pattern (like, say, an ES6 |
Oof, looks like we've been waiting a while for this: #7237. |
This can be solved using interfaces and/or definite assignment assertions which also work for class properties (see this section). |
Oh cool, this is why JSDoc in Javascript isn't working. That sucks. Also means that the workaround won't work. |
Search Terms
@method
@property
Suggestion
It would be great to add support for
@method
and@property
(and maybe@memberof
) now that annotations are on their way.I found bug #15715 that only talks about
@property
support but I think this makes more sense to see those in a same light because they should have a very common implementation and moreover they meet the same goals as a whole. At least I think and I explain my reasoning about this below!Use Cases
I have functions that do add methods and/or getters on a class right now, waiting for annotations to get their way in JS/TS. But let's say this: when annotations are here, those 2 flags support will be needed anyway (or at least I think so: I don't see how to make IntelliSense work without those)!
And tomorrow with annotations:
Examples
I'd like to be able to document those doing something like:
Or at least to be able to document them in the class itself:
With support of these, I would expect
vscode
to suggest to me thefoo
method and thebar
property when completing properties of a value of typeTest
.Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: