Skip to content

Can't rename private fields #36481

@mjbvz

Description

@mjbvz

From microsoft/vscode#89542

TypeScript Version: 3.8.0-dev.20200128

Search Terms:

  • private fields
  • rename

Code

class Foo { 
    #name = 1;

    boo() {
        console.log(this.#name);
    }
}

Trigger a rename on #name

Bug
The result we get back says we cannot rename the element (but it also seems to return the locations to rename)

[Trace  - 19:09:36.772] <semantic> Sending request: rename (578). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/x.ts",
    "line": 2,
    "offset": 9,
    "findInStrings": false,
    "findInComments": false
}
[Trace  - 19:09:36.774] <semantic> Response received: rename (578). Request took 2 ms. Success: true 
Result: {
    "info": {
        "canRename": false,
        "localizedErrorMessage": "You cannot rename this element."
    },
    "locs": [
        {
            "file": "/Users/matb/projects/san/x.ts",
            "locs": [
                {
                    "start": {
                        "line": 2,
                        "offset": 5
                    },
                    "end": {
                        "line": 2,
                        "offset": 10
                    },
                    "contextStart": {
                        "line": 2,
                        "offset": 5
                    },
                    "contextEnd": {
                        "line": 2,
                        "offset": 15
                    }
                },
                {
                    "start": {
                        "line": 5,
                        "offset": 26
                    },
                    "end": {
                        "line": 5,
                        "offset": 31
                    }
                }
            ]
        }
    ]
}

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbolEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions