Skip to content

Rename field to a name with dash does not transform the field with quotes. #30879

@drake7707

Description

@drake7707

TypeScript Version: 3.5.0-dev.20190412

Search Terms: hyphen refactor, dash rename

Code

interface TestObject {
    test:string
}
const instance: TestObject = { test: "hello" };
console.log(instance.test);

Rename "test" to a variable with a hyphen, e.g "te-st"

Expected behavior:
Code is refactored to use quotes:

interface TestObject {
    "te-st":string
}
const instance: TestObject = { "te-st": "hello" };
console.log(instance["te-st"]);

Actual behavior:

Refactor replaces the variable as given, producing invalid code

interface TestObject {
    te-st:string
}
const instance: TestObject = { te-st: "hello" };
console.log(instance.te-st);

Playground Link: Replacing all occurrences in the playground also includes all Test matches, so I tested this in vscode

Related Issues: none I could find

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions