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

Re: [jslint] Error reported by JSLint I don't understand

Expand Messages
  • Douglas Crockford
    ... You can specify types of properties with the /*properties */ directive. It can take a wildcard type as *. So, /*properties query: * */
    Message 1 of 9 , Jul 6, 2011
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Jérôme DESPATIS <jerome@...> wrote:
      >
      > Thanks for your answer,
      >
      > As it's a type confusion, of course I can hide them with tolerate type
      > confusion.
      > But this setting is quite useful, I prefer to correct the error, and
      > force JSLint to check for type confusion.
      >
      > The fact is I really don't understand why there's type confusion here...
      >
      > Here is a short code that does nothing, with a Type confusion, someone
      > could explain me why there's a type confusion please ?
      >
      > JSLint reports the error:
      >
      > Problem at line 4 character 36: Type confusion: function and '[': array.
      >
      > djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query': {'type': ...

      You can specify types of properties with the /*properties */ directive. It can take a wildcard type as *. So,

      /*properties query: * */
    • Joshua Bell
      ... Try this minimal example: var x = { sort: [] }; Error: Problem at line 1 character 17: Type confusion: function and [ : array. The value of the object
      Message 2 of 9 , Jul 6, 2011
      • 0 Attachment
        On Wed, Jul 6, 2011 at 11:05 AM, Jérôme DESPATIS <jerome@...>wrote:

        > Here is a short code that does nothing, with a Type confusion, someone
        > could explain me why there's a type confusion please ?
        >
        > JSLint reports the error:
        >
        > Problem at line 4 character 36: Type confusion: function and '[': array.
        >
        > djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query': {'type':
        > ...
        >
        >
        > ------------- JS code -----------------
        >
        > /*global djTagonomyStore */
        > function djTagonomyInit() {
        > "use strict";
        > djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query':
        > {'type': "proposal"}, 'onComplete': function (items, request) {
        > }});
        > }
        > ------------------------
        >

        Try this minimal example:

        var x = { sort: [] };

        Error: Problem at line 1 character 17: Type confusion: function and '[':
        array.

        The value of the object property 'sort' is an array, which is a naming
        conflict with the JavaScript built-in Array.prototype.sort function.


        [Non-text portions of this message have been removed]
      • Jérôme DESPATIS
        Ok thanks Douglas ... -- Jérôme Despatis jerome@despatis.com [Non-text portions of this message have been removed]
        Message 3 of 9 , Jul 8, 2011
        • 0 Attachment
          Ok thanks Douglas

          Le 06/07/2011 20:15, Douglas Crockford a écrit :
          >
          > --- In jslint_com@yahoogroups.com
          > <mailto:jslint_com%40yahoogroups.com>, Jérôme DESPATIS <jerome@...> wrote:
          > >
          > > Thanks for your answer,
          > >
          > > As it's a type confusion, of course I can hide them with tolerate type
          > > confusion.
          > > But this setting is quite useful, I prefer to correct the error, and
          > > force JSLint to check for type confusion.
          > >
          > > The fact is I really don't understand why there's type confusion here...
          > >
          > > Here is a short code that does nothing, with a Type confusion, someone
          > > could explain me why there's a type confusion please ?
          > >
          > > JSLint reports the error:
          > >
          > > Problem at line 4 character 36: Type confusion: function and '[': array.
          > >
          > > djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query':
          > {'type': ...
          >
          > You can specify types of properties with the /*properties */
          > directive. It can take a wildcard type as *. So,
          >
          > /*properties query: * */
          >
          >


          --
          Jérôme Despatis
          jerome@...



          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.