Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Incorrect function return type for jQuery setter functions #3684

Open
RaymondLim opened this issue May 1, 2013 · 7 comments
Open

Incorrect function return type for jQuery setter functions #3684

RaymondLim opened this issue May 1, 2013 · 7 comments

Comments

@RaymondLim
Copy link
Contributor

jQuery has overloaded functions; both setters and getters have the same name, but setters have some extra parameters and most of them return jQuery object for chaining.

  1. In a js file type $("div").css("display", "none").
  2. Type a dot to chain the call with other jQuery api.

Result: You get hints for string methods instead of jQuery methods.

@ghost ghost assigned eztierney May 3, 2013
@njx
Copy link
Contributor

njx commented May 3, 2013

Reviewed. Marking medium priority to @eztierney for sprint 25 since it seems like a common case.

@eztierney
Copy link
Contributor

I looked through the jQuery docs, and I found 3 methods like this:
attr
css
prop

I didn't see any other methods which looked like they were overloaded like this, but I may have missed some.

@RaymondLim
Copy link
Contributor Author

three more -- height, width and html.

@njx
Copy link
Contributor

njx commented May 9, 2013

A few more: offset(), text(), scrollLeft(), scrollTop(), .val(). (I found these by searching for "or set" on http://api.jquery.com/. There might be others, but these seem like the most common.)

@petetronic
Copy link
Contributor

Erik logged a Tern bug, see the comments in ternjs/tern#123.

@petetronic
Copy link
Contributor

Removing Sprint 25 milestone as we're dependent on a fix in Tern

@redmunds
Copy link
Contributor

Was assigned to tern team, so marking "Needs Review".

@dangoor dangoor self-assigned this Apr 1, 2014
@dangoor dangoor changed the title [js code hints] Incorrect function return type for jQuery setter functions. Incorrect function return type for jQuery setter functions Apr 24, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants