Skip to content
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

Please allow jsdoc at function parameter #7533

Closed
Thaina opened this issue Mar 16, 2016 · 7 comments
Closed

Please allow jsdoc at function parameter #7533

Thaina opened this issue Mar 16, 2016 · 7 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@Thaina
Copy link

Thaina commented Mar 16, 2016

Some function take complicate type such as function callback. I want to document it inline at the parameter but it seem salsa don't parse jsdoc there

image

@billti
Copy link
Member

billti commented Mar 16, 2016

We don't support inline block comments currently. For now, you can always write multi-line block comments before the callback function, e.g.
screen shot 2016-03-15 at 9 02 45 pm

@billti
Copy link
Member

billti commented Mar 16, 2016

Note that placing an inline comment where you have it poses challenges if you have more than one parameter, as JsDoc @ tags are separated by newlines. The Google closure compiler does support just adding a type immediately before the parameter (e.g. function(/** number */ index){...}). We could consider that at a later point

@billti billti added Suggestion An idea for TypeScript Salsa labels Mar 16, 2016
@billti billti added this to the TypeScript 2.1 milestone Mar 16, 2016
@Thaina
Copy link
Author

Thaina commented Mar 16, 2016

I see thank you

Confirmed I can do this

image

And this

image

@billti
Copy link
Member

billti commented Mar 16, 2016

Great! Thanks. Interesting that I notice using the second form you show only works with a line break before the param. We should probably not require this (i.e. just allow it inline).

@mhegazy mhegazy added Bug A bug in TypeScript and removed Suggestion An idea for TypeScript labels Mar 17, 2016
@evmar
Copy link
Contributor

evmar commented Mar 18, 2016

Note: Closure supports inline types as you mention, but in Closure, functions have other non-type "stuff" they worry about. For example optional params are written @param {number=} opt_foo and as far as I understand it you cannot use = in an inline type, it's specific to function params.

Another way of saying this is that /** X */ in Closure allows a type X, but @param {Y} is the parameter syntax Y which includes types but also optionality. I imagine (but haven't verified) that rest arguments (with ...) work similarly.

@aluanhaddad
Copy link
Contributor

@martine I believe that optionality is indeed a type level concern.

@mhegazy mhegazy assigned sandersn and unassigned RyanCavanaugh Sep 29, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Sep 29, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Sep 29, 2016

Should be fixed in the next release of TypeScript TS 2.1.

@mhegazy mhegazy closed this as completed Sep 29, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

7 participants