- changed component to Completion
Include type hints in JSDocs for Lightning
Steps:
- Create a Lightning component & controller
- create a method
doInit
- annotate the method with the following
/**
*
* @param cmp {Component}
* @param event
* @param helper
*/
doInit: function(cmp, event, helper)
- Start typing in the method body
cmp.find('foo').
Expected behavior: I get an autocomplete pop-up with all of the methods that you've documented in Component.js
Actual Behavior: no pop-up
This can be fixed by adding * @return {Component}
to the jsDoc for the find
method
Comments (5)
-
Account Deactivated reporter -
repo owner Andy, I apologize but I'm not sure I understand the issue. Here's what I see when I type
component.f
in IntelliJ IDEA Ultimate Edition or WebStorm's JavaScript editor (note that none of this will work in Community Edition):I've also verified that if you rename
component
tocmp
, it yields the same results. Note, though, that our JSDoc is slightly different with mine having@param {Type} name
and yours having@param name {Type}
as documented here:http://usejsdoc.org/tags-param.html#names-types-and-descriptions
However, just for completeness' sake, I did swap the order and saw the same correct results in the IDE.
As for changing the JSDoc, if you do find errors, you'll need to log them against the official Aura project as the JavaScript API interfaces for Lightning/Aura are pulled directly from that project and only modified to extract the accessible interfaces (i.e., function bodies are stripped for efficiency).
Please let me know if I'm misunderstanding the nature of this reported issue or if you're not seeing the same behavior.
-
repo owner - changed status to resolved
I'm going to resolve this as unable to reproduce based on the comment I just added, but if I've misunderstood the issue or if you're doing exactly what I describe and are seeing different behavior, please open with appropriate details.
-
Account Deactivated reporter You've provided a good answer: fixing the docs in the Aura codebase.
The issue was on the result of
cmp.find().
, notcmp.
I'd love both to produce the same results, as they are both components. -
repo owner Ah, I see now. You're wanting to get completions off of
cmp.find()
which should evaluate toComponent
. Sorry, not sure how I missed that as you described it perfectly. Yeah, I've sent some other feedback to the Aura team about their JSDoc. I'd definitely recommend that you do the same, or perhaps even provide a pull request to them if they'll accept it. Thanks for clarifying! - Log in to comment