Best Practices for IntelliSense JavaScript references

青春壹個敷衍的年華 提交于 2020-01-12 08:24:10

问题


Assuming a person has Visual Studio 2008 set up correctly for JavaScript Intellisense, what are the best practices for the actual javascript reference declarations?

The basic form, of course, is (right up at the top of the file):

///<reference path="path-to-file.js" />

But what are the rules for the path?

Webapps

Should web applications use forward slashes like a url? "filename.js" for files in the same directory? "./filename.js"? Root relative "/path/to/filename.js"? Are all of these supposed to work? Do relative paths like "../../filename.js" work?

Class Libraries

What about when building class libraries of embedded resource .js files? Should these use backslashes like a Windows file path? Escaped double backslashes like in a .NET string literal?

What about when a .js file in a webapp references one in a class library? This could commonly be the case during development of a plugin - you have a set of existing plugins, and you develop a new one in a web context so you don't have to keep rebuilding the class library, and then when you're done you move it into the class library. How would you reference that? By full "C:\long\path\to\project\directory\file.js"?

Cascading Dependencies

What about if A.js references B.js which references C.js which references D.js, all from different directories?

Should A.js contain references to B, C, and D, or should the references cascade to A.js?

More??

I'll enable the Community Wiki so that hopefully this can become a compendium of best practices.


回答1:


Check out these two blog entries. They should answer most of your questions:

http://blogs.msdn.com/webdevtools/archive/2008/11/18/jscript-intellisense-faq.aspx

http://blogs.msdn.com/webdevtools/archive/2007/03/02/jscript-intellisense-in-orcas.aspx



来源:https://stackoverflow.com/questions/978224/best-practices-for-intellisense-javascript-references

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!