Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
Specifies documentation information, including a description, for either a field or member that's defined on an object.
Syntax
<field name="fieldName" static="true|false"
type="FieldType" integer="true|false"
domElement="true|false" mayBeNull="true|false"
elementType="ArrayElementType" elementInteger="true|false"
elementDomElement="true|false" elementMayBeNull="true|false"
helpKeyword="keyword" locid="descriptionID"
value="code">description
</field>
Parameters
name
The name of the field or member. When the <field> element is used in a constructor function, name is required and defines the member to which the tag applies. When the <field> element is directly annotating a field, this attribute is ignored, and the name used by Visual Studio is the name of the actual field in the source code.
static
Optional. Specifies whether the field is a member of the constructor function or a member of the object returned by the constructor function. Set to true to treat the field as a member of the constructor function. Set to false to treat the field as a member of the object returned by the constructor function.
type
Optional. The data type of the field. The type can be one of the following:
An ECMAScript language type in the ECMAScript 5 specification, such as
NumberandObject.A DOM object, such as
HTMLElement,Window, andDocument.A JavaScript constructor function.
integerOptional. IftypeisNumber, specifies whether the field is an integer. Set totrueto indicate that the field is an integer; otherwise, set tofalse. This attribute is not used by Visual Studio to provide IntelliSense information.domElementOptional. This attribute is deprecated; thetypeattribute takes precedence over this attribute. This attribute specifies whether the documented field is a DOM element. Set totrueto specify that the field is a DOM element; otherwise, set tofalse. If thetypeattribute is not set anddomElementis set totrue, IntelliSense treats the documented field as anHTMLElementwhen performing statement completion.mayBeNullOptional. Specifies whether the documented field can be set to null. Set totrueto indicate that the field can be set to null; otherwise, set tofalse. The default value isfalse. This attribute is not used by Visual Studio to provide IntelliSense information.elementTypeOptional. IftypeisArray, this attribute specifies the type of the elements in the array.elementIntegerOptional. IftypeisArrayandelementTypeisNumber, this attribute specifies whether the elements in the array are integers. Set totrueto indicate that the elements in the array are integers; otherwise, set tofalse. This attribute is not used by Visual Studio to provide IntelliSense information.elementDomElementOptional. This attribute is deprecated; theelementTypeattribute takes precedence over this attribute. IftypeisArray, this attribute specifies whether the elements in the array are DOM elements. Set totrueto specify that the elements are DOM elements; otherwise, set tofalse. If theelementTypeattribute is not set andelementDomElementis set totrue, IntelliSense treats each element in the array as anHTMLElementwhen performing statement completion.elementMayBeNullOptional. IftypeisArray, specifies whether the elements in the array can be set to null. Set totrueto indicate that the elements in the array can be set to null; otherwise, set tofalse. The default value isfalse. This attribute is not used by Visual Studio to provide IntelliSense information.helpKeywordOptional. The keyword for F1 help.locidOptional. The identifier for localization information about the field. The identifier is either a member ID or it corresponds to thenameattribute value in a message bundle defined by OpenAjax metadata. The identifier type depends on the format specified in the <loc> tag.valueOptional. Specifies code that should be evaluated for use by IntelliSense instead of the function code itself. For<field>, this attribute is supported for constructor functions, but is not supported for object literals. You can use this attribute is to provide type information when the field type is undefined. For example, you can usevalue=’1’to treat the field type as a number.descriptionOptional. A description for the field.
Remarks
The name attribute is required when you're documenting a field in a constructor function. For all other scenarios, all attributes for the <field> element are optional.
When you're documenting a constructor function, the <field> element must appear immediately before the field declaration. The name attribute must match the field name that's used in the source code. For object members, the name attribute can be omitted if the <field> element appears immediately before the object member declaration.
Example
The following code example shows how to use the <field> element.
// Use of <field> in an object definition.
var Rectangle = {
/// <field type='Number'>The width of the rectangle.</field>
wid: 5,
/// <field type='Number'>The length of the rectangle.</field>
len: 0,
/// <field type='Number'>Returns the area of the rectangle.</field>
getArea: function (wid, len) {
return len * wid;
}
}
// Use of <field> in a constructor function.
// The name attribute is required.
function Engine() {
/// <field name='HorsePower' type='Number'>The engine's horsepower.</field>
this.HorsePower = 150;
}
Example
The following example shows how to use the <field> element with the static attribute set to true.
function Engine() {
/// <field name='HorsePower' static='true' type='Number'>static field desc.</field>
}
Engine.HorsePower = 140;
// IntelliSense on the field is available here.
Engine.
Example
The following example shows how to use the <field> element with the static attribute set to false.
function Engine() {
/// <field name='HorsePower' static='false' type='Number'>Non-static field desc.</field>
}
Engine.HorsePower = 140;
var eng = new Engine();
// IntelliSense on the field is available here.
eng.
Example
The following example shows how to use the <field> element with the value attribute.
function calculator(a) {
/// <field name='f' value='1'/>
}
new calculator().f. // Completion list for a Number.