-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Add documentation requirements for @template
descriptions, similar to @param
#1120
Add documentation requirements for @template
descriptions, similar to @param
#1120
Comments
You can get the {
match: [
{
disallowName: '/^$/',
tags: [
'template',
],
},
],
}, For For You could use {
contexts: [
{
comment: 'JsdocBlock:not(*:has(JsdocTag[tag=template]))',
context: 'ArrowFunctionExpression,FunctionDeclaration,FunctionExpression,TSDeclareFunction',
message: '@template required on each block',
},
],
}, |
that certainly works in the meantime, but I'd assume type parameters are just as important to document as parameters? why wouldn't we want to make it a more straightforward process for requiring an explanation as to what is expected to be passed in? |
Can you give me a precise example of code where you'd like to see @template required? |
@brettz9 sure, here's an example I'm working with: /**
* A tuple of the coordinates and the value at the coordinate.
*/
export type Pairs<D, V> = [D, V | undefined];
/**
* For a particular axis, a tuple representing the element before
* and after
*/
export type BeforeAfter<D, V> = [Pairs<D, V>, Pairs<D, V>]; |
Ok, I see, so you are using TypeScript syntax rather than using JavaScript with a TypeScript flavor and you want to enforce So I see a need for We might be able to add our |
makes sense, I requested the others because it seems to match the established pattern, no problems nixing that. |
We probably could use, however, a separate rule (in addition to the |
And we might not just check TypeScript proper, but check any Also, in the |
I've added a PR to provide some support, but so far, only for the type alias structures (at root or exported) which you indicated. Maybe we can just release it now and gradually build support for other structures, as I'm sure there are many that could be supported. |
Please feel free to enable the rule and try it out... |
Sorry, i've been on vacation, I'll take a look tonight and thank you for your hard work on this! |
🎉 This issue has been resolved in version 48.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Just note that there are now two rules, |
@brettz9 It's a nice addition, thank you! However, I get errors with these two new rules: Error: No parslet found for token: 'keyof' with value 'keyof' For the following: /**
* Gets the values of `T`.
* @template {Record<any, any>} T - Type to get the values of
* @typedef {T[keyof T]} ValueOf
*/ Should I open an issue about it? |
@Arkellys That is likely not due to the two new rules, but to the lack of support for the TypeScript |
@brettz9 Ahh yes, I'm aware of this issue, that's why I had to create the |
We could really use someone in the know about parsers helping out with the type parser. |
I think with the additions to date, these two rules are now mature enough to close the issue. Feel free to report desire for support of other type structures not yet covered. |
Motivation
To better support and require generic type descriptions via
@template
Current behavior
No rules require
@template
to be defined, or require a description if it is defined.Desired behavior
The following rules are created/added:
This rule should detect if a generic is added to a function, class, type alias or interface and perform
the same functionality as
jsdoc/require-param
Alternatives considered
None, could not find this functionality, only similar patterns
The text was updated successfully, but these errors were encountered: