3

Trying to get accustomed to Visual Studio's XML javascript comment syntax. I have a question specifically about type. Say I have a custom type such as...

namespace.types.User = function(_id, _name) {
    /// <field name="id" type="Number">ID of the user</field>
    /// <field name="name" type="String">Name of the user</field>
    this.id = _id;
    this.name = _name;
};

If I want to reference that type in a <field> later on I would do something like...

namespace.session = function() {
    /// <field name="CurrentUser" type="namespace.types.User">The current User of the session</field>
    this.CurrentUser = new namespace.types.User('foo', 'bar');
};

However, when I do this Intellisense will show me the description of what .CurrentUser means but it will not show any suggestion for either .id or .name. In other words it acts like it's just a plain object with no other type data.

How can I get VS intelligence to pickup the richer description of custom objects?

1 Answer 1

1

Try putting in the xml comments for the parameters in the function signature.

namespace.types.User = function(_id, _name) {
   /// <param name="_id" type="Number" /></param>
   /// <param name="_name" type="String" /></param>
}

It doesn't seem like ///<field></field> syntax helps with the intellisense for field values, its only picks up intellisense from assignment. Thus since it doesn't know what the type of the incoming parameters are, they are not passed onto the fields.

You would think that add ///<field></field> would override the type intellisense for field. Especially if you have ever used a IDE or a tool that supports intellisense from code comments. But that does not currently seem the case in VS 2010.

Also you probably don't want to use namespace as a variable or identifier, even if its for an example or replacement for the actual namespace.

Namespace is a reserved keyword for javascript. (though some people like mozilla have reserved package instead).

Sign up to request clarification or add additional context in comments.

1 Comment

It appears that VS2012 still does not honor the <field /> comment to override intellisense for javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.