トップ回答者
AMD pattern (requirejs) and Visual Studio intellisense

質問
-
Has anyone tried out requirejs for their metro apps? It works fine for me, but I have troubles with the IntelliSense when using it.
I tryied to use the xml comments (as used by the base.js/ui.js) combined by the "/// <reference path=" pattern to include IntelliSense from files. Doing so, it works well for class defined in sync, but I don't get any IntelliSense for those defined into the AMD. For exemple, here is the AMD file:
/// <reference path="ms-appx://Microsoft.WinJS.1.0.RC/js/base.js" /> /// <reference path="ms-appx://Microsoft.WinJS.1.0.RC/js/ui.js" /> (function () { "use strict"; var MyClass = WinJS.Class.define(function () { /// <summary> /// Commment for MyClass /// </summary> }); WinJS.Namespace.define("MyNamespace", { MyClass: MyClass }); define([], function () { var MyClass2 = WinJS.Class.define(function () { /// <summary> /// Commment for MyClass /// </summary> }); WinJS.Namespace.define("MyNamespace2", { MyClass2: MyClass2 }); return MyClass2; }); })();
And how I try to use it :
/// <reference path="TestIntelli.js" /> (function () { "use strict"; new MyNamespace.MyClass(); // IntelliSense working new MyNamespace2.MyClass2(); // IntelliSense not working })();
Any idea why I lose intellisense it doesn't work, and how I could make it work?
- 移動 Jeff SandersMicrosoft employee, Moderator 2012年7月17日 19:33 Tools intellisense question (From:Building Metro style apps with HTML5/JavaScript)
2012年7月17日 17:38
回答
-
I finally made it works using the Visual Studio extensibility described at http://msdn.microsoft.com/en-us/library/hh874692(v=vs.110).aspx.
I used the project at https://github.com/jrburke/requirejs-intellisense which didn't work for me. So I made some changes to it so it supports all "overloads" of define and force a call to the module when called in define by Visual Studio intellisense. This way, the Namespace.define and Class.define are called and IntelliSense come back to life.
- 回答としてマーク Instriker 2012年7月17日 20:23
2012年7月17日 20:23
すべての返信
-
I finally made it works using the Visual Studio extensibility described at http://msdn.microsoft.com/en-us/library/hh874692(v=vs.110).aspx.
I used the project at https://github.com/jrburke/requirejs-intellisense which didn't work for me. So I made some changes to it so it supports all "overloads" of define and force a call to the module when called in define by Visual Studio intellisense. This way, the Namespace.define and Class.define are called and IntelliSense come back to life.
- 回答としてマーク Instriker 2012年7月17日 20:23
2012年7月17日 20:23 -
That sounds great! Could you please share your changes or submit a pull request on GitHub? I'm encountering the same issues and it's not clear how to make the same changes you did based on your comments.2012年8月18日 5:19