UPDATE: be sure to see official response at the end of this post.
As Joel D'Souza and I were discussing VS10 JavaScript Intellisense it became clear that, while it is overall an improvement from 2008, there is one silly bug.
MS Connect Bug: https://connect.microsoft.com/VisualStudio/feedback/details/553372/vs10-javascript-intellisense-class-member-decorator-display-depends-on-microsoftajax-js
In exploring javascript intellisense in VS10, it came to my notice that enums, interfaces and namespaces and classes all are decorated properly by adding the proper tag properties, but the class member decorators, e.g. events and properties etc, fail to display unless MicrosoftAjax.js was referenced.
The line in MicrosoftAjax.js that 'triggered' the proper display of class member decorators is:
Object.__class = true;
Surely it is an oversight or bug that an intrinsic feature of Visual Studio is rendered faulty by a line in a referenced script.
I also bugged that intellisense and code completion for fields was broken in December and provided a code sample to repro. Apparently I got a response asking for steps to repro but I have not been monitoring the email address I bugged that one under. And in any case, the only additional information I can give is how to add the originally provided code to a VS10 project and try to get intellisense on a field. Which I did ;-)
This made it into RTM as well.
So the only way to get code completion for a field is to declare in on the prototype in your -vsdoc.js but you will not get intellisense.
Without 'Object.__class' tag
With 'Object.__class' tag
In Action
Official response:
Hi Sky,
Thank you for your feedback. In order to get class member decorators to work properly, you need to set the constructor field of the prototype of the class to the constructor. Without doing that, the constructor is set to Object constructor by default (which is why your workaround works as well). So I would recommend doing the following (which is exactly what registerClass does in MicrosoftAjax.js)
MyNamespace.MyClass.prototype = {
constructor: MyNamespace.MyClass,
...
}
Regards,
Alex Gavrilov
Visual Studio Web Development Tools
Technorati tags:
VisualStudio,
JavaScript,
Intellisense,
Bug