Skip to content

Refactor -> Move to a new file/Move to file fail if contains dependency function call #62115

@EnixCoda

Description

@EnixCoda

Type: Bug

I noticed that Refactor -> Move ... not work occasionally. I did some investigation and below is the minimal reproducible example.

Part 1 - string template tag function

I have not find any dependency that moving its template string tag function works.

// index.js
// `good__` prefix means `Move ...` works on that variable, otherwise `fail__`

import { local } from "./local";
export const good__localTemplate = local``;

export const good__undeclaredTemplate = undeclaredTemplate``;

import dedent from "dedent"; // you can use any package installed locally
export const fail__dedent = dedent``;

import { default as renamedDefault } from "dedent";
export const fail__renamedDefault = renamedDefault``;

import { notExistingExport } from "dedent";
export const good__notExistingExport = notExistingExport``;

import notInstalled from "not-installed";
export const good__notInstalled = notInstalled``;
Part 2 - general function

Sometimes moving dependency function works.

import { add } from "lodash";
export const good__lodashAdd = () => add();

import { createStore } from "@reduxjs/toolkit";
export const fail__reduxCreateStore = () => createStore();

In order to reproduce it locally, please do install dedent, lodash, @reduxjs/toolkit in your package.

VS Code version: Code 1.102.1 (Universal) (7adae6a56e34cb64d08899664b814cf620465925, 2025-07-15T16:41:17.147Z)
OS version: Darwin arm64 24.5.0
Modes:

System Info
Item Value
CPUs Apple M1 Pro (10 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 8, 8, 7
Memory (System) 32.00GB (0.11GB free)
Process Argv --crash-reporter-id 0955f262-3647-42ae-8be7-e0a76907fed4 --crash-reporter-id 0955f262-3647-42ae-8be7-e0a76907fed4
Screen Reader no
VM 0%
Extensions disabled
A/B Experiments
vsliv368:30146709
binariesv615:30325510
vscrpc:30673769
962ge761:31350689
h48ei257:31000450
nativeloc1:31344060
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
hdaa2157:31222309
copilot_t_ci:31333650
e5gg6876:31282496
pythoneinst12:31285622
c7cif404:31314491
pythonpulldiag:31343502
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
0aa6g176:31307128
747dc170:31275177
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
pylancequickfixt:31350061
9d2cg352:31346308
usemarketplace:31343026
nesew2to5:31336538
agentclaude:31350858
nes-diff-11:31337487
replacestringexc:31350595
nes-set-on:31350020
6abeh943:31336334
yijiwantestdri0626-t:31336930
0927b901:31350571
f76d9909:31348711
0cj2b977:31350606
a02b4192-color:31350622

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbolHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions