microsoft / microsoft/TypeScript

JSDoc : add support for @method (and @property)

Ouverte
#28,730 5 commentaires 20 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Domain: JavaScript Domain: JSDoc In Discussion Suggestion
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
132

Description

Search Terms

  • JSDoc
  • @method
  • @property
  • support

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)!

/**
* Some class
 * @class
 */
class Test {
  /* whatever */
}

// this adds a #foo() method on the class prototype as well as a #bar getter(/setter)
someMethodAddingABehavior(Test, ...params);

And tomorrow with annotations:

/**
* Some class
 * @class
 */
@someAnnotationAddingABehavior(...params)
class Test {
  /* whatever */
}

Examples

I'd like to be able to document those doing something like:

/**
 * What foo is doing is great!
 * @method foo
 * @param {string} testParam some testing parameter
 * @returns {string} some random string
 * @memberof Test.prototype
 */
/**
 * Bar is awesome too!
 * @property {number} bar
 * @memberof Test.prototype
 */
someMethodAddingABehavior(Test, ...params);

Or at least to be able to document them in the class itself:

/**
* Some class
 * @class
 */
class Test {
  /* whatever */

  /**
   * What foo is doing is great!
   * @method foo
   * @param {string} testParam some testing parameter
   * @returns {string} some random string
   */
  /**
   * Bar is awesome too!
   * @property {number} bar
   */
}

With support of these, I would expect vscode to suggest to me the foo method and the bar property when completing properties of a value of type Test.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Aucun fichier source ni test n’est nommé. Commencez par localiser la gestion existante des annotations JSDoc et le chemin utilisé pour VS Code IntelliSense, puis déterminez comment @method et @property doivent contribuer aux membres de Test. Le travail est terminé lorsque les méthodes et propriétés externes documentées apparaissent dans la complétion, sans modifier le JavaScript généré.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, typescript, vscode
Domaine
compilers, developer-experience
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.