microsoft / microsoft/TypeScript

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

Open
#30,879 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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

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

Reproduce the rename in VS Code using the TypeScript example, changing test to te-st. Trace the rename refactor behavior for the interface property, object literal, and member access; done means all affected references use valid quoted properties and bracket access as shown in the expected output, with regression coverage added in the relevant test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.