tern
tern copied to clipboard
Undefined "$(fn)" method in JQuery module.
Since "$(fn)" is undefined by JQuery module, validation modules like Lint keep showing error like this.
[Lint]: Invalid argument at 1: cannot convert from Function.prototype to string|Node|Array
"$(function() {})" is marked as an error. While equivelent "$(document).ready(function() {})" is fine.
What tool are you used for lint?
I'm using Spring Tool Suite(3.9.4.RELEASE) with Tern Eclipse IDE(1.2.0.2016061608) from Eclipse Marketplace. I tried "Lint" Validator. Results look like this:

Do you use this def: https://github.com/ternjs/tern/blob/master/defs/jquery.json The message seems not match the def.
Can you try https://gist.github.com/othree/27cf283cf8b66f0f9cf9ca69fc0aeb46
I added tern-def-jquery.json in "\plugins\ternjs_1.2.0.201606160856\node_modules\tern\defs" from IDE folder and used it without other original JQuery modules. But same results. This is the original jquery.json from the plugin: jquery.zip
I just found out that if I uncheck all jQuery related modules, the errors changed like this.

The def is a little bit out of date. Ok, I can confirm error at line 74 and 80 matches the def. Still not sure error at line 79.
Did you try the one I provided above. Line 14 is different.
Yes. I replaced everything in jquery.json.
How about change line 14 to
"!type": "fn(selector: ?, context?: frameElement) -> jQuery.fn",
And restart IDE to make sure the Tern server restarted
It partially worked.

Sorry for changing lines. I'll try to keep it from now on.
Can you try this one: https://github.com/othree/tern/blob/jquery-def/defs/jquery.json
If everything works fine. I will merge back to here. But you will need to wait releases for both Tern and Tern Eclipse IDE(for upgrade Tern version).
It worked! No error.
Can you help me test one more sample code? (Sorry I didn't get the environment ready)
$('div').click({data: 1}, function (event) {
event;
});
I hope this code sample could have no errors and event have correct auto complete candidate.
Thanks
I pasted your code below the original code. No error. But... I just noticed that after I changed JSON, there was no auto-completes too. In fact, there is no error whatsoever; even with wrong syntax.
I have updated it and it should work now. https://github.com/othree/tern/blob/jquery-def/defs/jquery.json But there is still some issue I need to fix before I can merge back.
The problem is that jQuery.click (and similar methods) use something like polymorphism.
The first parameter can be an event handler or data.
Which is not good for TernJS.
It works. Auto-completes works too. Thank you.
