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

Basic support for JSDoc @param {function} #561

Closed
wants to merge 1 commit into from

Conversation

angelozerr
Copy link
Contributor

This PR provides a basic support for JSDoc {function} :

/**
 * @param {function} fn
**/
function test(fn) {
}

It should be improved to :

  • support args of function :
/**
 * @param {function(number)} fn
**/
function test(fn) {
}
  • support this of function :
/**
 * @param {function(this:number)} fn
**/
function test(fn) {
  this. // here Ctrl+Spaces shows methods of number.
}

In other words it should be cool to have the same features than JetBrains. See http://blog.jetbrains.com/webide/2012/10/validating-javascript-code-with-jsdoc-types-annotations/

@marijnh
Copy link
Member

marijnh commented Jun 15, 2015

Is this specified somewhere? I can't find anything about it on in the JSDoc docs.

@angelozerr
Copy link
Contributor Author

@marijnh you are right, it seems that JSDoc doens't support that. @callback is used for that. See :

So it should be cool if doc_comment could support @callback.

Perhaps it could be interesting to gives the capability to extends doc_comment to support a custom syntax?

@marijnh
Copy link
Member

marijnh commented Jun 15, 2015

Wow, that's a strange community. They seem entirely unable to deal with recursive syntax, or to grasp the fact that typedefs could already play the part of defining function types, or to notice that callback isn't a proper name for all function types.

So, um, when something is finally decided on, I guess we could support it. I'd also be okay with supporting the much saner Google Closure syntax. But I'd want an actually useful implementation that also parses parameter and return types -- just saying that something is a function can already be done by using Function as its type, I'm not sure this patch adds anything.

@angelozerr
Copy link
Contributor Author

Yes you are right we can use @param {Function} instead of using @param {function}. My patch give sthe capability to useFunctionorfunction`.

But my orignal problem is for my tern-lint. I have a validator which validates if a token is a function. To do that I do type.getFunctionType(). In the case when type is a Function.prototype, it returns null. I don't know if it's a bug?

marijnh added a commit that referenced this pull request Jun 24, 2015
@marijnh
Copy link
Member

marijnh commented Jun 24, 2015

I didn't know Function.prototype was a function (the only function, apparently, whose prototype is Object.prototype). Attached patch fixes this. Does that solve your problem?

@paulvi
Copy link
Contributor

paulvi commented Jul 20, 2015

👍 sign up

@marijnh marijnh closed this Nov 25, 2015
@paulvi
Copy link
Contributor

paulvi commented Nov 25, 2015

please comment why just closing in #561 and #438

@marijnh
Copy link
Member

marijnh commented Nov 26, 2015

There was no further response for five months, so I assumed the discussion was over.

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

Successfully merging this pull request may close these issues.

3 participants