Skip to content

Move to new file refactor misses shorthand property referencing importΒ #59131

Open
@rijx

Description

πŸ”Ž Search Terms

shorthand property refactor

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about shorthand properties

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAZxtApnAZlCI4CIB0A9EqrgNwBQFhhcAbggMYQAmaAtAHxwBKK6AQ0bIocLnACyEOmmRwAdigDuGYABsUVGpOnB5AczgwAFsAQYArvOHAI8uEvVq4UFDAF6jxtKEiwKKAAefvDoVjZ2cAIAFACUcADeFHApcMzyCBAa+GoQ+tEJJK4AvrGUxVq0UnR6hiZmltYwtvaOas6uINKy3nC+0DABwQONEfYARnGJyanpmdm5+UUoZRQVQA

πŸ’» Code

import store from "./store";

// vscode -> Refactor -> Move to new file

// Moving this function will retain the import
export function a() {
    console.log({store});
}

// Moving this function will remove the import
export function b() {
    console.log(store);
}

πŸ™ Actual behavior

Import statement is removed when function b is removed.

πŸ™‚ Expected behavior

Import statement is retained when function b is removed because it's used by function a.

Additional information about the issue

Happens in vscode and when using LanguageService.getEditsForRefactor.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions