Skip to content

Completions defined in editor.autocomplete don't work on type aliases #7501

Open
@mediremi

Description

@mediremi

I have a module BeltMapX with utility functions for working with Belt.Map.t.

I tried to set up autocomplete for pipe completion in rescript.json like so:

"editor": {
  "autocomplete": {
    "Belt.Map.t": ["BeltMapX"],
  }
}

This didn't work so I did some debugging in analysis/src/CompletionBackEnd.ml, and it turned out that mainTypeId is actually Belt_Map.t.

let mainTypeId = TypeUtils.findRootTypeId ~full ~env typ in
let typePath = TypeUtils.pathFromTypeExpr typ in
match mainTypeId with
| None ->
if Debug.verbose () then
Printf.printf
"[pipe_completion] Could not find mainTypeId. Aborting pipe \
completions.\n";
[]
| Some mainTypeId ->

Updating my rescript.json config to use the unaliased type, as below, worked.

"editor": {
  "autocomplete": {
    "Belt_Map.t": ["BeltMapX"],
  }
}

Would it be possible to make the completions backend handle type aliases so that "Belt.Map.t": ["BeltMapX"] works?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions