Visual Studio 2012 JavaScript Intellisense Not Working - javascript

I have Visual Studio 2012 installed on my laptop and desktop. On my desktop PC, the JavaScript intellisense is not working. For any method it pulls up (even standard JavaScript calls) I receive the message, "Intellisense was unable to determine an accurate completion list for this expression".
I've tried all of the suggestions from the other posts and tried everything I could find on Google. Nothing has worked. It isn't about not having JQuery Intellisense. I don't get even basic JavaScript Intellisense.
Edit:
The objects in the above images are simple strings, yet I don't get any help from the Intellisense.

I had the same problem: in Visual Studio 2010 I was used to add a reference in my javascript files, at the top, like this:
/// <reference path="/scripts/jquery-1.7.1-vsdoc.js" />
With the new Visual Studio 2012 this was not working anymore, I looked around and found the solution to put the reference in /scripts/_references.js I did so, not working.
What I was doing wrong was that I was referencing the vsdoc.js file, or at the moment of writing, nuget downloaded jquery 1.9.1 package, reference to jquery-1.9.1.intellisense.js which is WRONG.
The correct reference (if using the /scripts/_references.js file) is:
/// <reference path="/scripts/jquery-1.9.1.js" />
(NOT the .intellisense.js or the -vsdoc.js file).
For the global solution to work on all your projects: copy all the jquery files (main, minified, map, and intellisense one, to be sure) in C:\Program Files (x86)\Microsoft Visual Studio 11.0\JavaScript\References (adapt the path if you installed Visual Studio 2012 somewhere else) and in Visual Studio, under Tools > Options > Text Editor > Javascript > Intellisense > References > Add a reference to jquery-1.9.1.js (again, NOT the vsdoc or intellisense file, but the main one) as explained in the solution by denas (but it was not clearly said not to point the vsdoc/intellisense file).
Hope this helps.

Many things can cause problems like this, but I usually follow these steps to troubleshoot it.
close visual studio and restart
reboot windows and start visual studio again
have another developer load your project and test it
create a bare bone project and test with all stock javascript references
reset IDE
run VS in safe mode and test your project
uninstall and reinstall vs
I usually resolve most of the VS problems at step 3 or 4, and sometimes 5.

If you've installed VS on anything other than the C Drive this will happen.
In Visual Studio, under Tools > Options > Text Editor > Javascript > Intellisense > References
Add references to the same .js files that exist in the list but pointing to the new path where you have VS installed
eg - G:\Program Files\Microsoft Visual Studio 11.0\JavaScript\References.libhelp.js
There are 5 of them
After this go to Edit> Intellisense > Refresh external references

I fixed the same problem by right-clicking the file in Solution Explorer and choosing Open With and then choosing Web Form Editor if you're editing a Web form or Source Code (Text) Editor if you're editing a JavaScript file.

In visual studio 2012,
Using this solution https://github.com/jmbledsoe/angularjs-visualstudio-intellisense.
Make sure put ng, ngCookies modules into required fields. For example:
var module = angular.module("demo", ['ng','ngCookies']);

An excellent article by Mads Kristensen helped me fix the JavaScript Intellisense issue.
Triple-slash references look like this and can be added to
the top of any .js file or in /scripts/_references.js file
/// <reference path="../app/respond.js" />
REF: http://madskristensen.net/post/the-story-behind-_referencesjs

Related

Visual Studio crashing when i change .js file

I am working on a Visual Studio MVC project. (Version = 2013 )
When I try to write any javascript code in .js file or .cshtml file Visual Studio crashing and restarting.
When I open Menu > Tools > Options > Text Editor > Javascript menu and disable "Auto list members" and "Parameter information" the problem is solving.(There is no any crashing)
But I cant see properties of javascript functions on editor. (Because i disabled it to remove crashing error on previous step.I have already tried to delete .suo file and rebuild solution method but not worked on my project. There is still crashing if i write javascript code. )
How can I solve this crashing problem without disable to Auto list members" and "Parameter information" properties?
I'm using Resharper and had the same problem, the solution whas to deactivate Intellisense in Resharper => Options => Environment => IntelliSense => General for .js files
Restart Visual Studio in Administrator mode.
If the same issue still occurs, try to move your project to another directory.
I had same problem few months ago, I could not find the answer so I tried to install another version of VS. Installing Visual Studio 2017 solved it.

Visual Studio 2015 fails at opening java script files after TypeScript installment

The project contains both c# and javascript source code. And I use visual studio 2015 (3) for the development. Since installing the TypeScipt 2.0.3 I cannot open the .js source files in editor. The message that pops up is:
An error occurred trying to load the page.
No exports were found that match the constraint:
ContractName Microsoft.CodeAnalysis.Editor.TypeScript.ScriptContexts.ITypeScriptProjectProvider
RequiredTypeIdentity Microsoft.CodeAnalysis.Editor.TypeScript.ScriptContexts.ITypeScriptProjectProvider
And it is also appearing in the TypeScript Build tab under solution properties.
Has anyone experienced the same issue or has any ideas on how to solve this? I'd like to edit the .js files in Visual Studio.
Try deleting the folder
"C:\Users\<userName>\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache"
and then restart Visual Studio. This worked for me.
Delete the following folder and restart Visual studio.
C:\Users\yourusername\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
N.B. : The AppData folder may not appear on the first place. Unhide all hidden items from View tab and then follow the path.

Visual Studio 2017: js file causes many typescript errors

Please see the edit below
I have used the following package as a base for my VS Project ->
https://github.com/AngularClass/angular2-webpack-starter
Everything worked nicely in Visual Studio code, I then tried to convert it to a Visual Studio 2017 Project (node.js web)
Now some problems appeared
VS seems to install TypeScript definitions into a special folder C:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\#types
Additionally I included #types/node in my package.json which resulted in the appropriate node_modules folder.
now VS complains with error code TS4090 (Conflicting defintions for 'node').
Is there a possibility apart from deleting the folder in \AppData to tell VS which #types it should use?
The whole integration of TypeScript isn't really clear to me...
Does MSBuild recognize an existing tsconfig.json? or would I have to configure it in in the project-file as seen here?
EDIT
I just noticed that I was actually editing a .js file.
As soon as I changed the extension to .ts every warning and error vanished.
I also got many typescript errors (like TS2307, can't find module '#angular/core') before changing the extension from .js to .ts
The file just did an import (from node)
import * as fs from 'fs';
Could anyone explain why I got this errors?
Why a JS files causes 200+ typescript errors (some don't even seem related to the import from above)?
EDIT2
the errors which occur are
TS2403 - Subsequent Variable declarations must have the same type.
TS2300 - Duplicate identifier 'PropertyKey'
TS4090 - Conflicting definitions for 'node' found (paraphrasing: found in ./node_modules and C:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\#types
All the errors are caused by d.ts files in C:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\#types or C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TypeScript\lib.es6.d.ts
like Bowden Kelly noted, this seems the cause for this problems seems to be the definition files MS put in here C:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\#types, as soon as I install my own definition files in ./node_modules VS finds both definitions (if present) when editing JS files.
So the solution would either be:
doing it the MS Way
somehow exclude MS Directory
This is a BUG related in https://github.com/Microsoft/TypeScript/issues/14565
I was able to eliminate the errors by enabling
For JavaScript, try to uncheck/disable the "new JavaScript language service" under Tools > Options > Text Editor > JavaScript/TypeScript > Language Service. This seemed to help me when I opened random JavaScript files and the error window would go crazy.
Regarding the Angular 2 errors (cannot find module #angular/core), if there is a tsconfig.json in the project directory both Visual Studio and the TS compiler will use that. If you close an reopen the solution everything on the TypeScript tab of project properties should be disabled.
Once you know tsconfig.json is working, if you are using TS 2.x the compiler should find and use the types that come with angular 2 under node_modules/#angular/core/index.d.ts, unless you have a setting in tsconfig that overrides this like types: [].
I have still not been able to figure out 100% what is going on in Visual Studio Errors window since I still get sporadic unjustified errors (I know this because I can still compile). I do know that the Visual Studio TypeScript Language Service is what controls errors and intellisense in the Visual Studio IDE and it is tied to a specific version of TypeScript (2.1 in VS 2017). The errors have always caused problems in both VS 2015 and now VS 2017 also. I think it comes down to the inner workings of the extremely undocumented TypeScript Virtual Projects, for which I have still not found a purpose.
These links are useful reading:
http://blog.angular-university.io/typescript-2-type-system-how-do-type-definitions-work-in-npm-when-to-use-types-and-why-what-are-compiler-opt-in-types/
http://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types
https://github.com/Microsoft/TypeScript/issues/14540
The definition files installed to C:\Users\MyUser\AppData\Local\Microsoft\TypeScript\node_modules\#types are used for giving JavaScript IntelliSense only. If you have TypeScript in your project or a project configured with a tsconfig.json, you need to fetch your own .d.ts files and store them in your project. Luckily this project comes with all the .d.ts files you need already in the package.json a simple npm install should do the trick.
I can tell you that the conflicting definitions with 'node' are likely due to having 2 copies of the node.d.ts file. If you manually installed one yourself, on top of the one included in the projects package.json, then you'll get those errors.
I'm not certain about the TS errors you are getting in your JavaScript file. Can you show me an example of one of the errors and a snippet of the code causing it?
Also you probably don't want integration with MSBuild as this project is already setup to run with npm scripts + webpack. You should check out this plugin: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.NPMTaskRunner
Finally I don't think you want to be inside a Node.js web project. For this project, you are probably best off just opening the folder in VS. To do that just use File > Open > Folder... and navigate to your root folder. This will give you all the editing tools you need without any MSBuild or VS project structure. Considering this project wasn't designed to take advantage of any of those features, it'll probably be easier just to ignore them for now.
Please let me know what other issues you run into.
FYI, this has been fixed in Visual Studio 17.2 🙂

Intellisense and JsHint support for Ext Js in VisualStudio

I want to work with Senach Ext Js in a Website project in VisualStudio 2013.
The problem: VisualStudio respectively WebEssentials throws warnings like:
JsHint (W117): 'Ext' is not defined.
Here is the situation as it looks today:
The project is exactly what Sencha Cmd produced for me.
At the moment I want only a Website project and no server sided code involved (therefore I did not make a MVC or Web API project).
I know that there is a way to define some global symbols in each JavaScript file for JsHint, but I want to get the intellisense working too. So I am looking for the correct configuration for both use cases: WebEssential JSHint Warnings and Intellisense.
Maybe both problems need to be addressed separately. That would be fine too.
Is my directory structure correct (just took what Sencha Cmd built for me)?
How to address the problem to make intellisense working?
(How to avoid Webessential JavaScript warnings (it seems most or all of them are JsHint)?)
Update: Related question:
Enabling JSHint Support for Ext.js in Intellij Idea
Update:
"An _references.js file in any other location than
“~/Scripts/_references.js” will be just like any other JS file and
won’t be used for global intellisense. Even putting the file in the
root of your web project will not work as well."
Source: http://gurustop.net/blog/2012/03/03/javascript-js-intellisense-auto_complete-in-visual-studio-11-beta-the-web-_references-js-file/
still not working when I have the _references in a new "Script" folder:
So it seems like the final answer was to add a file called ~/scripts/_reference.js and then include a line to reference Ext JS in there. This enables Visual Studio to index the Ext JS source for Intellisense. For example:
/// <reference path="../ext/ext-all-debug-full.js" />
More on the Intellisense and _reference.js:
http://msdn.microsoft.com/en-us/library/bb385682.aspx
Note that due to the size of the Ext JS codebase, Visual Studio might take a few minutes to complete the indexing process and for Intellisense to start working smoothly.

Intellisense while editing JS files

I am creating project in Visual Studio. While editing JS in a HTML file, since we have included the reference to all JQuery files on top, we get intellisense for jquery instances. But, when we are editing JS files, we don't get any intellisense at all! Is there any way to get intellisense there too?
Assuming you're talking about Visual Studio, try adding the following line to the top of your .js file.
/// <reference path="~/path/to/your/jquery.js"/>
Also, if you're using anything other than the version of jQuery that was packaged with Visual Studio, you'll need a jquery-x.x.x-vsdoc.js file that matches your jquery filename, and put that vsdoc in the same directory as your jQuery library.
(For example, if you are using jquery-1.5.2.min.js, you will want jquery-1.5.2-vsdoc.js in the same directory of your project)
You can get the applicable vsdoc file at this page:
http://appendto.com/community/jquery-vsdoc
You seem to be implying that you are using Visual Studio to edit your JS files. If so, perhaps the JScript Editor Extensions extension for VS would work for you. It adds support for Intellisense inside JS files.

Categories

Resources