Skip to content

"Move to a new file" breaks the declaration of referenced variable #50654

@panlina

Description

@panlina

Issue Type: Bug

  1. Create a new js file, with following content:
var a = require('./a');
function f() {
	a;
}
  1. Select declaration of f, hit ⌘ + ., and select "Move to a new file".

image

Expected behavior:
A new file with declaration of f is created, and declaration of a is left unchanged.

Actual behavior:
A new file with declaration of f is created, but declaration of a becomes:

var = require('./a');

VS Code version: Code 1.68.1 (30d9c6cd9483b2cc586687151bcbcd635f373630, 2022-06-14T12:48:37.209Z), and Code 1.71.0 (784b0177c56c607789f9638da7b6bf3230d47a8c, 2022-09-01T07:25:25.516Z)
OS version: Darwin arm64 21.3.0
Restricted Mode: No

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbolEffort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Help WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions