-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Skip typedef in services getJSDocTags #43677
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
Conversation
|
@mjbvz You might have an opinion about this as well. |
|
From editor meeting:
|
It seems fairly useful to preserve this typedef in the quick info for The problem is, it may be hard to reason about what doc comments are “purely typedef-like” from their tags: /**
* @deprecated
* @see Some newer type that you should use instead
* @author Andrew Branch
* @typedef {Object} Foo
* @property {string} email
* @property {number} whatever
*/
function foo() {}Two alternative strategies for deciding what comments to remove come to mind:
|
|
andrewbranch's point 2. makes the most sense to me. |
|
I'd rather vote for the strategy 1 and avoid significant blank lines. |
|
I looked at my usual corpora [1] to see which strategy is best. I started by considering three options:
I found all comments containing .ts files.ts files had almost 300
/**
* @typedef {function} Typename
* @param {number} a
* @param {string} b
* @return {string}
* @this {?object} Please don't pass `this` it is the worst.
*/Also, notably, in protobufjs, the .js files.js files had more than 8000
6 projects use the unsupported callback-like typedefs compared to 3 projects that use local typedefs. Additionally, I observed plenty of unassociated AnalysisThe best rule for excluding typedefs in quickinfo is (1). Except for local typedefs, all typedef-containing comments that I saw were exclusively about that typedef. And, although both local typedefs and callback-like typedefs are rare, it's better to show a few callback-like typedefs than to hide local typedefs that were intentionally defined in-place. (2) won't work well because there it's too hard to capture the set of associated tags -- we would end up showing any unforeseen variants needlessly. And the data show that (3) is both unnecessary and ineffective. In the future, if we decide to support callback-like typedefs, then (1) would stop incorrectly showing the callback-like typedefs. The code to implement this wouldn't be large, although I think there isn't much demand. [1] A full install of Definitely Typed, using @definitelytyped/dtslint-runner to |
andrewbranch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it 🐙
| && jsdoc.tags.some(t => t.kind === SyntaxKind.JSDocTypedefTag || t.kind === SyntaxKind.JSDocCallbackTag) | ||
| && !jsdoc.tags.some(t => t.kind === SyntaxKind.JSDocParameterTag || t.kind === SyntaxKind.JSDocReturnTag)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth an explanatory comment? This looks puzzling without the context of the conversation we had in this PR.
@typedefand@callbacktags when generating quickinfo for a declaration. They are unattached tags that happen to be attached to a particular node because of the way the compiler works.@typedefand@callbacktags. Again, these are attached because of an implementation detail.For example:
The idea is that the comment text of a jsdoc that contains other tags probably describes both tags.
This is big-ish change in a poorly tested area of services (though with fourslash baselines, it's getting better!). I don't think this should go into 4.3.
Fixes #43534