I am trying to get intellisense in VS2008 in a js file, foo.js, from another js library/file I've written but cannot figure out the reference path ?syntax?/?string?
The library is in a file called common.js which is in the same folder as foo.js I'm working on.
Here's the paths I've tried...
/// <reference path="../../scripts/common.js"/>
/// <reference path="/../scripts/common.js"/>
/// <reference path="../scripts/common.js"/>
/// <reference path="/scripts/common.js"/>
/// <reference path="scripts/common.js"/>
/// <reference path="/common.js"/>
/// <reference path="../common.js"/>
/// <reference path="/common.js"/>
/// <reference path="common.js"/>
What's the secret path syntax/string that I'm missing?
FWIW the top path is what is set in the master page of this MVC app...like so
<script type="text/javascript" src="../../scripts/common.js"></script>
Thanks Greg
IntelliSense based on TypeScript declaration files For example, JavaScript IntelliSense can be provided for values declared in a . d. ts file (see TypeScript documentation), and types such as interfaces and classes declared in TypeScript are available for use as types in JsDoc comments.
The “reference” comment allows you to “see” functions and objects outside of your current file in the completion list.
Tip: To check if a JavaScript file is part of JavaScript project, just open the file in VS Code and run the JavaScript: Go to Project Configuration command. This command opens the jsconfig.json that references the JavaScript file. A notification is shown if the file is not part of any jsconfig.json project.
First, make sure "common.js" is in your web project. Then drag "common.js" from the solution explorer into the editor window for the file you want to reference it from.
Finally...finally got jQuery intellisense to work...
From here http://blogs.msdn.com/webdevtools/archive/2007/11/06/jscript-intellisense-a-reference-for-the-reference-tag.aspx
the author says
Here are a few other subtle tips:
- Remember, reference statements must precede all other content in the file-even normal comments.
And that was what fixed the issue for me...placed the reference statements at the very top and... voila!... intellisense works!
So just for grins here's what the first lines of my file look like
/// <reference path="common.js" />
/// <reference path="jquery-1.2.6.js" />
/// <reference path="jquery.formatCurrency.js" />
/*
* Foo Scripts/foo Script: foo.js
* Version 1.0
* Copyright(c) 2008 FUBAR Management, LLC. All Rights Reserved.
*/
Originally I had the reference statements below the Foo Scripts comments arghhhh!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With