atom-typescript icon indicating copy to clipboard operation
atom-typescript copied to clipboard

Autocomplete parentheses, arrow functions

Open cedrikaagaard opened this issue 5 years ago • 1 comments

The "Autocomplete parentheses" option doesn't work for arrow functions and this would be a nice feature to have.

cedrikaagaard avatar Feb 28 '21 12:02 cedrikaagaard

It would be, but I don't know how to fix this. TSServer reports bound array functions as const, which they are. And parsing the info it returns about type is probably not very robust. Here's an example:

{
  "name": "test",
  "kindModifiers": "",
  "kind": "const",
  "displayParts": [
    {
      "text": "const",
      "kind": "keyword"
    },
    {
      "text": " ",
      "kind": "space"
    },
    {
      "text": "test",
      "kind": "localName"
    },
    {
      "text": ":",
      "kind": "punctuation"
    },
    {
      "text": " ",
      "kind": "space"
    },
    {
      "text": "(",
      "kind": "punctuation"
    },
    {
      "text": ")",
      "kind": "punctuation"
    },
    {
      "text": " ",
      "kind": "space"
    },
    {
      "text": "=>",
      "kind": "punctuation"
    },
    {
      "text": " ",
      "kind": "space"
    },
    {
      "text": "void",
      "kind": "keyword"
    }
  ],
  "documentation": []
}

That's pretty much all we can coax out of tsserver. I don't know how to decide whether we need to add parentheses or not based off this. If anyone has suggestions -- feel free to chime in.

lierdakil avatar Mar 01 '21 01:03 lierdakil