microsoft / microsoft/TypeScript
Distinguishing suggestions from global scope from local suggestions
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
From https://github.com/Microsoft/vscode/issues/59437
Search Terms:
- TSServer
- completions
- suggestions
Code
For the example ts file:
class FooClass {
toString(): void {
|
}
}
Trigger suggestions at the | inside the toString method
Problem
We get back two completions from completionInfo:
{
"name": "toString",
"kind": "function",
"kindModifiers": "declare",
"sortText": "0"
},
{
"name": "toString",
"kind": "method",
"kindModifiers": "",
"sortText": "0",
"insertText": "this.toString"
},
However when we then make the completionEntryDetails request, we can only pass the identifier name: "toString". This makes it unclear which completion entry we are actually requesting completion details for.
Proposal
completionEntryDetails already has a source field that is used to identify when a suggestion is an auto import. I believe that this field could also be used for global symbols, such as when a symbol name comes from a global lib.d.ts file. In this case, the first toString suggestion comes from a global in dom.d.ts
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the FooClass example to reproduce the duplicate toString completions returned by completionInfo. Read how completionEntryDetails currently uses source for auto imports, then evaluate the proposed global-symbol case from dom.d.ts; done means callers can distinguish the entries and request the matching details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100