Skip to content

Better support for JSDoc param tags when setting properties in argument lists? #782

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

Closed
karl opened this issue Oct 20, 2010 · 3 comments
Closed
Labels

Comments

@karl
Copy link

karl commented Oct 20, 2010

While attempting to document some CoffeeScript for the Google Closure Compiler, I realised that @param tags wouldn't correctly match up the compiled JavaScript when I used @variables in the parameter list.

Example:

###*
@param {number} footSize The size of the monkey's foot
###
setFootSize = (@footSize) ->

Compiles to:

var setFootSize;
/**
@param {number} footSize The size of the monkey's foot
*/
setFootSize = function(_arg) {
  this.footSize = _arg;
};

Where the parameter comes out as _arg rather than footSize.

Any chance we would want to change this so that the parameters keep their names without the @ prefix? I know this was discussed when allowing @s in parameters lists came up, but I can't find the ticket.

What do people think?

@hen-x
Copy link

hen-x commented Oct 20, 2010

My original objection was about making footSize seem like an alias to @footSize, without actually being a true alias. Consider:
setFootSize = (@footsize) ->
footSize += 1
@footsize -= 1
[footSize, @footsize]

setFootSize(7) # would produce [8, 6]

@jashkenas
Copy link
Owner

Agreed -- I don't think we should give them the same name, as the this property will always be set first, and changing the param later will have no effect.

If you'd like to document this for closure, you can always do it normally:

###*
@param {number} footSize The size of the monkey's foot
###
setFootSize = (footSize) ->
  @footSize = footSize

@karl
Copy link
Author

karl commented Oct 20, 2010

Thanks setharus, I thought there was a good reason it is like it is now, but couldn't remember what it was. Thanks for jolting my memory.

Happy to leave things as they are, and use the expanded version in jashkenas's example.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants