Skip to content

flow CLI autocomplete command and get-def command doesn't recognize methods and properties of an object that starts with "$" ( dollar char ) #5906

Open
@pichillilorenzo

Description

@pichillilorenzo

For example I have this piece of code on a file called test.js:

// @flow

let a = {
  $test: 3
}
a.AUTO332

If I execute flow autocomplete --json --pretty < test.js, it gives me only:

{
  "result":[
    {
      "name":"hasOwnProperty",
      "type":"(prop: any) => boolean",
      "func_details":{"return_type":"boolean","params":[{"name":"prop","type":"any"}]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":50,
      "endline":50,
      "start":5,
      "end":38
    },
    {
      "name":"isPrototypeOf",
      "type":"(o: any) => boolean",
      "func_details":{"return_type":"boolean","params":[{"name":"o","type":"any"}]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":51,
      "endline":51,
      "start":5,
      "end":34
    },
    {
      "name":"propertyIsEnumerable",
      "type":"(prop: any) => boolean",
      "func_details":{"return_type":"boolean","params":[{"name":"prop","type":"any"}]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":52,
      "endline":52,
      "start":5,
      "end":44
    },
    {
      "name":"toLocaleString",
      "type":"() => string",
      "func_details":{"return_type":"string","params":[]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":53,
      "endline":53,
      "start":5,
      "end":28
    },
    {
      "name":"toString",
      "type":"() => string",
      "func_details":{"return_type":"string","params":[]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":54,
      "endline":54,
      "start":5,
      "end":22
    },
    {
      "name":"valueOf",
      "type":"() => Object",
      "func_details":{"return_type":"Object","params":[]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":55,
      "endline":55,
      "start":5,
      "end":21
    }
  ]
}

without the $test property.

If I change the property name from $test to t$est it works:

// @flow

let a = {
  t$est: 3
}
a.AUTO332

So, executing again flow autocomplete --json --pretty < test.js, it gives me:

{
  "result":[
    {
      "name":"hasOwnProperty",
      "type":"(prop: any) => boolean",
      "func_details":{"return_type":"boolean","params":[{"name":"prop","type":"any"}]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":50,
      "endline":50,
      "start":5,
      "end":38
    },
    {
      "name":"isPrototypeOf",
      "type":"(o: any) => boolean",
      "func_details":{"return_type":"boolean","params":[{"name":"o","type":"any"}]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":51,
      "endline":51,
      "start":5,
      "end":34
    },
    {
      "name":"propertyIsEnumerable",
      "type":"(prop: any) => boolean",
      "func_details":{"return_type":"boolean","params":[{"name":"prop","type":"any"}]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":52,
      "endline":52,
      "start":5,
      "end":44
    },
    {
      "name":"t$est",
      "type":"number",
      "func_details":null,
      "path":"-",
      "line":4,
      "endline":4,
      "start":10,
      "end":10
    },
    {
      "name":"toLocaleString",
      "type":"() => string",
      "func_details":{"return_type":"string","params":[]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":53,
      "endline":53,
      "start":5,
      "end":28
    },
    {
      "name":"toString",
      "type":"() => string",
      "func_details":{"return_type":"string","params":[]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":54,
      "endline":54,
      "start":5,
      "end":22
    },
    {
      "name":"valueOf",
      "type":"() => Object",
      "func_details":{"return_type":"Object","params":[]},
      "path":"/private/tmp/flow/flowlib_32caa231/core.js",
      "line":55,
      "endline":55,
      "start":5,
      "end":21
    }
  ]
}

In fact, t$est now is listed.

So there are problems with methods and properties that starts with "$" ( dollar char ). This problem arise also with the get-def command.
Instead with type-at-pos command, the method/property is recognized and the type is returned correctly.

Flow version: 0.66.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions