rescript-lang / rescript-lang/rescript

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

Open
#7,501 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
7.5k
Forks
485
Avg merge
1d 2h
Merged PRs (30d)
55

Description

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.

https://github.com/rescript-lang/rescript/blob/7b4bc420cd052e492aea6b607df8f7513210b422/analysis/src/CompletionBackEnd.ml#L1068-L1077

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in analysis/src/CompletionBackEnd.ml at the handling referenced around lines 1068-1077, and compare the configured type name Belt.Map.t with the resolved Belt_Map.t. The work is done when autocomplete configured with the aliased type name produces completions for BeltMapX, while the existing unaliased configuration continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers, developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.