Skip to content

Private field completions unexpectedly include insertText #36119

@mjbvz

Description

@mjbvz

From microsoft/vscode#88305

TypeScript Version: 3.8.0-dev.20200108

Search Terms:

  • suggest / suggestion / suggestions
  • completion / completions
  • private fields
  • completionInfo

Code
For the TS:

class K {
    #value: number;

    private keyword: number = 1;

    foo() {
       this.#va
    }
}
  1. Trigger completions after #va

  2. Accept suggestion for #value

Expected behavior:
The suggestion results in this.#value:

Actual behavior:

After the suggestion, there is an extra this.:

class Prv {
    #value: number;

    private keyword: number = 1;

    foo() {
        return this.this.#value;
    }
}

I believe the root cause is that insertText is being included for this completion item:

   {
            "name": "#value",
            "kind": "property",
            "kindModifiers": "",
            "sortText": "3",
            "insertText": "this.#value"
        },

Compare this with completions for private properties, which in a similar case do not include insertText:

        {
            "name": "keyword",
            "kind": "property",
            "kindModifiers": "private",
            "sortText": "0"
        },

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions