What is the _references.js used for? - javascript

What is the _references.js file used for in a new ASP.NET MVC 4 project?

In VS 11, Visual Studio will give you intellisense from all files
that have references in the “_references.js” file.
For More Info

MSDN documentation: JavaScript IntelliSense
In brief, _references.js stores the list of JS files paths, for which you want the Visual Studio to gather and build the intelisense (aka "code complete"). The VS project adds there some common JS libraries like jQuery to build the intellisense for it. You can add a reference to your custom JS file in form like this:
/// <reference path="MyScriptFile.js" />

From Visual Studio 2017 forward, this file is no longer used.

Related

Is the jsconfig.json file required to be used in every JavaScript project?

I am working with a JavaScript project. Is it is necessary (or recommended) to use the jsconfig.json file in every JavaScript project?
Will adding the jsconfig.json file make the development process easier, or is it only used for larger JavaScript projects?
I noticed that the jsconfig.json file has something to do with Visual Studio Code. How does it improve the developer experience with Visual Studio Code?
As a supplement, I’d like to say that in the official document. The LANGUAGES-JavaScript-JavaScript projects (file jsconfig.json) explains when we need this file.
The LANGUAGES-NODE.JS/JAVASCRIPT-Working with JavaScript explains its function, the parts of it, and some examples of writing this file, how to use a JavaScript support and so on.
You can refer to this: Working with JavaScript

Recommended way to add Typescript to an existing asp.net 4 Webforms project

I am working on quite an old asp.net 4.0 Webforms project in Visual Studio 2015.
I want to start using TypeScript instead of Javascript for some of the client side code. I have used TypeScript in other projects outside of Visual Studio (e.g. using Visual Studio Code, and the node tools such as npm, gulp etc)
Now, I am trying to see how to use the TypeScript in Visual Studio, and see quite a few conflicting posts, and various versions of TypeScript / VS referred to.
I have added a TypeScript file to VS, and VS reported it now supporting Typescript and added a few lines to the project file. A have also added the VS extension for Typescript (version 2)
I build my project and get the .js and .map files. The files are in CommonJS format so I need to either load these or convert using a some sort of bundling.
This is where I don't know where to go. Also, I have read conflicting reports on how to configure the Typescript (e.g whether or not Visual Studio will use a tsconfig.json file)
In non asp.net projects I have use gulp with the gulp-typescript browserify etc gulp plugins.
Do I do the same thing in my asp.net project, or is there some other way to bundle and convert the JS to browser usable code?
If I use the gulp method, I assume this then means I will now not be using the TS compiler installed via the Visual Studio plugin (so what is the point of this if it emits CommonJS formatted cod that I can't use in the browser?
Thanks in advance for any suggestions here!
Yes, Web forms can do TypeScript and Gulp. Below are some steps:
Configure npm
Configuring Bower
Configure Bootstrap and My CSS with Gulp
Update the Master page
Configure Gulp-Watch
A complete solution can be found here.
For TypeScript ,
Unless you have a .ts file created with "Add New Item" in your project, the option "TypeScriptCompile" on the "Build Action" of the file properties is not available and it raises an exception. After the first file is created, then you find this option and can manually set it to a .ts file.
The option "Typescript file" is not available in the "Add File" options unless you have a .ts file created with "Add New Item" in your project and you are in a "Scripts" folder (if you name differently the folder where you want to add this file, this option wont be available). Of course you can add a .ts file from "Add New Item".
Please read this SO thread Type Script Web Forms

Javascript reference and Intellisense in Visual Studio 2013 .coffee files

Just started using Web Essentials and love its support of .coffee files. Big problem however: In Visual Studio, if you add the following reference to the top of a .js file, Visual Studio will include intellisense for the items in the referenced file:
/// <reference path="../../js/knockout-3.1.js" />
So, while writing my code I can type something like ko. and intellisense shows me all the functions knockout has to offer.
However the above XML reference is not allowed in .coffee files and in fact keeps them from being compiled. I can put the following in a .coffee file:
# #reference ../../js/knockout-3.1.js
This will compile but I lose the intellisense in Visual Studio.
How can I "include" other .js files as a reference and trigger intellisense in a .coffee file?
This is not currently supported.
See this stack overflow question:
CoffeeScript Intellisense
Also see this suggestion from web essentials:
https://webessentials.uservoice.com/forums/140520-general/suggestions/3782958-coffeescript-intellisense
I use VS2015. The way i do it is update the "references.js" file (right click on that file and click update)
see screenshot

How to setup typescript development workflow in visual studio 2013?

I am using the typescript 0.9.1.1 in visual studio 2013 preview. I have a couple of questions about typescript development workflow.
1: How to let visual studio compile all typescript files into only one javascript source file.
2: How to generate the minified javascript file?
3: Could we have google closure "exportsymbol" feature in the typescript? If I want to all symbols in my_public_api.ts is kept as they are and all other symbol names should be obfuscated.
1.) How to let visual studio compile all typescript files into only one javascript source file.
You need to add the section <TypeScriptOutFile>Some.js</TypeScriptOutFile> to your project file manually.
2) How to generate the minified javascript file?
TypeScript compiler cannot do this. Use uglify.js OR google closure OR WebEssentials can
do this for you.
3.) Could we have google closure "exportsymbol" feature in the typescript? If I want to all symbols in my_public_api.ts is kept as
they are and all other symbol names should be obfuscated.
TypeScript compiler does not do any minification / obfuscation.

javascript intellisense in Visual Studio

How can I get JavaScript IntelliSense in Visual Studio 2008 and in Visual Studio 2010 ?
How can I get jQuery IntelliSense in Visual Studio 2008 and in Visual Studio 2010 ?
If I fail to get the above, let me know 'Which is the most used JavaScript Editor which can replace VS versions for editing javascript files?
or you can simply drag and drop your javascript into your .js file and it creates entry like this:
/// <reference path="jquery-1.6.2.js" />
worked fine on my VS 2010 (Premium version)
I'm using VS2010 with ReSharper 6 which adds powerful JS Intellisense support. Autocomplete works for all JS files in the solution as well as jQuery. But it's not free.
Go to Tools-Options-Text Editor-Javascript-Intellisense-References and place a reference to the intellisense files for the version of jquery you are using in the Implicit Web group.
OR
place an "add reference" to the intellisense file in the _references.js file which you can add to the Scripts folder of your project.
/// <reference path="jquery-1.8.2.js"/>
/// <reference path="jquery-1.8.2.min.js"/>
/// <reference path="jquery-1.8.2.intellisense.js"/>
Though this will only provide intellisense for the project you are in, the first will for any open js file.
To get the latest jquery files with intellisense use the nuget package installer which by default will create a scripts folder and place the jquery version.js, the min.js and intellisense.js files into... from there you can copy them to the location most of the Microsoft references are placed which is typically
C:\Program Files (x86)\Microsoft Visual Studio 11.0\JavaScript\References
VS 2008/2010 has built in JavaScript IntelliSense.
If you have the corresponding "-vsdoc.js" file next to your jQuery file VS 2010 offers IntelliSense out of the box and VS 2008 needs SP1 installed and the patch at http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736
No need, really.
http://archive.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736
Wow... I followed the method described above.. Awesome....
You should get the jQuery files from Asp.Net CDN. They have VSDOC and are able to give very good intellisense and documentation support.

Categories