Loading ...
Sorry, an error occurred while loading the content.

/*properties */

Expand Messages
  • Douglas Crockford
    The /*properties */ directive can now accept types. For example, the directive /*properties a: array, b: boolean, n: number, o: object, r: regexp, any: * */
    Message 1 of 1 , Jun 28, 2011
    • 0 Attachment
      The /*properties */ directive can now accept types. For example, the directive

      /*properties
      a: array, b: boolean, n: number, o: object, r: regexp, any: *
      */

      indicates that the properties a, b, n, o, r should only accept values having the indicated types. Additionally, the type * is a wildcard indicating any type.

      So
      foo.s = 1; // warning
      foo.s = ''; // ok
      foo.any = 1 // ok
      foo.any = ''; // ok

      Also, function is a type, as is function followed by one of the other types, where the second type is a function's return type.

      /*properties
      join: function string, slice: function *
      */

      The /*properties */ directive is generated as part of the function report.

      This is part of the type confusion checking service of JSLint. If you do not want to use this service, then click the 'Tolerate type confusion' option.
    Your message has been successfully submitted and would be delivered to recipients shortly.