WebStorm highlights all $-operators as "unknown" in a jQuery project - javascript

Maybe a newbie-question:
Why does my WebStorm IDE not recognize any jQuery code when on the other side the created page works well in the browser?
That's what I did:
I've installed WebStorm Version 2018.2.6.
Then I downloaded a simple jQuery demo project, this one:
http://javascriptbook.com/code/c07/example.html (the html-file, the css file and the .cs file).
Then I downloaded a minified jQuery, "jquery-3.3.1.min.js".
I put all the files in a folder, changed the relative paths and updated the jQuery filename, so in the html file it reads "<script src="jquery-3.3.1.min.js"></script> <script src="code.js"></script>"
When I view that via WebStorm (=when I launch Chrome and WebStorm provides the webserver), then everything works perfectly. Animation is done just nicely.
However, in the WebStorm IDE all occurrences of the $ operator in the .js file are marked as "unresolved function".
I found these articles:
phpstorm unresolved function or method $()
I can't add jQuery to WebStorm, why?
So I went to Languages & Frameworks | JavaScript | Libraries and download&installed "jquery". It's then listed as "#types/jquery".
However, the error highlighting is still there.
Do I need to make more source mofications or how do I get that working?

Types resolving won't work when using minified library version, but downloading typings (#types/jquery) should work:
make sure that the library is downloaded properly (can you see it in External libraries list in the Project tool window?); invalidating caches (File | invalidaate caches, Invalidate and restart) can also help

Related

'Require is not defined' in Netbeans - Javascript

I am new to Javascript and am interested in using a library from github. I am using netbeans to code and I have installed node.js. However, I am still getting the error 'Require is not defined'. I have installed 'browserify' as this seemed like a common solution, but I am still getting this error.
Am I doing something wrong?
Image of set up libraries
Update
I have also found that there is a problem with one of my libraries, think it could be relevant to the original problem.
Problem with library
If you are developing NodeJS based project, you should use NodeJS project type in NetBeans where require() is considered as known global function and as such NetBeans won't show the hint.You can change your current project to enable NodeJS support by right clicking on the project, select Project Properties -> NodeJS and check Enable NodeJS support.
If you are using RequireJS library, you can also enable RequireJS support in Project Properties in JavaScript Frameworks -> RequireJS
I guess this is because require() does not exist in the browser/client-side JavaScript.Can you give it a try to following statements;
Use <script> tag.
Use a CommmonJS implementation. Synchronous
dependencies like Node.js
Use an AMD implementation.
And keep library codes and application codes seperated. ( bundle.js and script.js )
Browserify will take all the script files necessary and put them into the "bundle.js" file, so you should only have to include "bundle.js" in the HTML file, not the "script.js" file.

VS2013: Publish minified bundle created on files outside of the project

I use Visual Studio 2013 and .NET 4.5 for an MVC project.
I've learning to use AngularJS via several videos on Pluralsight and one of them walks through the process of using Grunt to clean the output directory, then use ngmin to min-safe the Javascript files.
My process is using a gruntfile.js to clean and run ngmin against the javascript files in my solution, then put them in a directory called app_built. This is executed via a batch file in the pre-build for the project and then I include it via a ScriptBundle with IncludeDirectory pointing to the app_built directory. My intent is to use the Bundling features of .NET 4.5 to do the rest of the minification and concatenation of the Javascript after all the files have been min-safed via Grunt.
I specify the path to the min-safed files with the following:
bundles.Add(new ScriptBundle("~/bundles/minSafed")
.IncludeDirectory("~/app_built/", "*.js", true));
If I run this on my local machine, it runs fine without a hitch. The Javascript is minified and bundled as I'd expect and the resulting web application runs fine as well.
If I publish the website to a remote server, I get a server error that the "Directory does not exist. Parameter name: directoryVirtualPath". I assume this error is saying that it's unable to find the directory populated with my many *.js files. I also assume this is because they weren't published since they aren't part of the solution, even though the folder they reside in is a part of the solution (it's just empty within the solution explorer in Visual Studio).
If my assumption is correct, what can I do to add these files to my solution so they'll be published with the rest of my web application with minimal effort on my end each time?
And if I'm incorrect in the assumption, what I can I do to resolve this otherwise?
Thanks!
I never did find a great way of going about this. I found information at http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx that seems related, but I was unable to make it work.
Rather, since I knew the name of the outputted file, I simply created such an empty file in my project and referenced that where I needed to. I then had the pre-build task replace the contents of that file with the externally minified version and it would be packaged with the project as necessary, so it works well enough.

How to work with TypeScript in an MVC application

I'm using Visual Studio 2013 to create an MVC5 application. I decided to use TypeScript for the client side. I have TypeScript installed and more or less configured. When I build the project JavaScript files appear next the TypeScript files (*.js and *js.map).
The problem is that those files are not included in the solution. I can only see them when I select "Show All Files" in Solution Explorer or browse my solution folder with file explorer.
I see 2 bad consequences:
When I add a .js file to a view like that <script src="~/Scripts/Custom/Tmp.js"></script> Resharper complains "Project file expected at XYZ". However when I run the MVC application JavaScripts work fine.
If the .js files are not included in the solution they won't be published and so the webpage won't work properly.
The only solution that comes to my mind is to add the files manually, but:
this sounds very tedious
I think the .js files are not being added for some purpose
What's the proper way to use TypeScript in an MVC application?
My experience so far with a project just like yours is unproblematic. After working with TypeScript so much, it's become painful to look at JavaScript!
Problem 1) doesn't happen in plain VS suggesting that the issue is with ReSharper.
Problem 2) isn't. Deployment works somehow; the .js files are published but the .js.map files are not.

Cannot compile javascript files in NetBeans using Rhino

My goal is to create a project (don't know yet if it has to be html5 or java project) in netbeans, add js file with any line of code and then press compile it and run.
I wuld like to have my js files compile to *.class files as it can be done via js console according to rhino tutorial on mozilla page.
But as i said i would like to have it via pressing run/compile button in my netbeans
Currently i'm using netbeans 7.3(i'm honestly open to change version if necesarry) and windows
I already try to do many things but only 2 are worth describing:
-edit build.xml file to use js.jar from rhino
-just run java project with javascript files - according to some articles it should be possible but in my case in just left js files uncompiled
Please help
Aleksandra

How to enable jQuery Intellisense in Aptana?

I have Aptana and i installed Aptana Support for jQuery plugin.
Now i oped a javascript file, but can't see any jQuery Intellisense,
How to enable that?
I find the easiest way is to create a project in Aptana - you can choose which libraries to include in your project. Then pull the .js file into your project. It should give you jQuery intellisense then.
An additional way to achieve this (if all else fails I guess) is to download the file from https://raw.github.com/aptana/javascript-jquery.ruble/master/support/jquery.1.4.2.sdocml and drop it into the root of your project folder. This should give you intellisense in Aptana 3 (at least) where I tested it.
Check this:
Commands > Bundle Development > Install Bundle then select jQuery. Now jQuery appear in the Commands menu, ans you can use jQuery Snippets and intelisense.
I thinks that this only works in js files and not in script tag in HTML file.

Categories