Search code examples
phpstormjsdoc

Does PHPStorm understand @constructs or @constructor for JavaScript?


I'm a little confused as to which JSDoc describes a constructor function for a class, and if PHPStorm understands either.

When I research which JSDoc to use I keep coming across two versions. There is @constructs and @constructor.

  • Do these two tags mean the same thing?
  • Which tag should I use in my JSDoc?
  • Is there a benefit in PHPStorm for code complete or intellisense using either?

Here are some references.

https://code.google.com/p/jsdoc-toolkit/wiki/TagConstructor

https://code.google.com/p/jsdoc-toolkit/wiki/TagConstructs

Now I understand that @constructs should be used with @lends but why?


Solution

  • if you need to mark a function as a constructor, @constructor is the right choice. @constructs only applies to a lent function and may be used with @lends tag only (that can only appear on object literals). See this Wiki page for more info on @lends tag. Note that PHPStorm supports both tags for type hinting/navigation