TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

VSCode errors when refactoring JavaScript to new file

Open ProCode-Software opened this issue 1 year ago • 7 comments

Type: Bug

I was trying to copy some JavaScript functions to a new file using Refactor. I clicked Move to file and got the following notification:

<semantic> TypeScript Server Error (5.6.2)
Debug Failure. False expression: No interactive refactor arguments available
Error: Debug Failure. False expression: No interactive refactor arguments available
    at Object.getRefactorEditsToMoveToFile [as getEditsForAction] (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:144294:11)
    at Object.getEditsForRefactor (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:143422:31)
    at getEditsForRefactor2 (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:150903:32)
    at Proxy.<anonymous> (/home/procode/.vscode-server/extensions/vue.volar-2.1.6/node_modules/typescript-vue-plugin-bundle/index.js:5:1894)
    at IpcIOSession.getEditsForRefactor (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:192236:49)
    at getEditsForRefactor (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:190435:43)
    at /home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:192655:15
    at IpcIOSession.executeWithRequestId (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:192644:14)
    at IpcIOSession.executeCommand (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:192653:29)
    at IpcIOSession.onMessage (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/typescript.js:192701:68)
    at process.<anonymous> (/home/procode/.vscode-server/bin/d78a74bcdfad14d5d3b1b782f87255d802b57511/extensions/node_modules/typescript/lib/tsserver.js:525:14)
    at process.emit (node:events:519:28)
    at emit (node:internal/child_process:951:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

This happens when I use Move to existing file, not Move to new file.

VS Code version: Code 1.94.0 (d78a74bcdfad14d5d3b1b782f87255d802b57511, 2024-10-02T13:08:12.626Z) OS version: Windows_NT x64 10.0.22631 Modes: Remote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2

System Info
Item Value
CPUs Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz (8 x 1190)
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: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.77GB (2.26GB free)
Process Argv --crash-reporter-id f7f8d6dd-eb4b-4368-b4e3-4ee787923cae
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu-24.04
OS Linux x64 5.15.153.1-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz (8 x 0)
Memory (System) 7.64GB (5.23GB free)
VM 0%
Extensions (38)
Extension Author (truncated) Version
vscode-github-actions git 0.27.0
volar Vue 2.1.6
rtf ale 2.8.0
Handlebars and 0.4.1
icons-carbon ant 0.2.6
codeswing cod 0.0.25
vsc-material-theme Equ 34.7.5
vscode-firefox-debug fir 2.9.10
codespaces Git 1.17.3
remotehub Git 0.64.0
vscode-drawio hed 1.6.6
fluent-icons mig 0.0.18
symbols mig 0.0.20
dotenv mik 1.0.1
theme-monokai-pro-vscode mon 1.3.2
vscode-edge-devtools ms- 2.1.6
jupyter-keymap ms- 1.1.2
remote-containers ms- 0.388.0
remote-ssh ms- 0.115.0
remote-ssh-edit ms- 0.87.0
remote-wsl ms- 0.88.4
vscode-remote-extensionpack ms- 0.25.0
remote-explorer ms- 0.4.3
remote-repositories ms- 0.42.0
remote-server ms- 1.5.2
vs-keybindings ms- 0.2.1
vscode-speech ms- 0.10.0
material-icon-theme PKi 5.11.1
material-product-icons PKi 1.7.1
sqlite-viewer qwt 0.7.3
ayu tea 1.0.5
pdf tom 1.2.2
windows-terminal Tyr 0.7.0
roblox-lua Und 1.0.5
vscode-icons vsc 12.9.0
JavaScriptSnippets xab 1.8.0
jetbrains-product-icons yat 0.0.8
material-theme zhu 3.17.5

(21 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
vscaat:30438848
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
f3je6385:31013174
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
impr_priority:31102340
nativerepl1:31139838
refactort:31108082
pythonrstrctxt:31112756
flighttreat:31134774
wkspc-onlycs-t:31132770
nativeloc2:31134642
wkspc-ranged-t:31151552
cf971741:31144450
defaultse:31146405
iacca2:31150323
notype1:31151523
5fd0e150:31146321

ProCode-Software avatar Oct 08 '24 21:10 ProCode-Software

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.94.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

It still doesn't work

ProCode-Software avatar Oct 08 '24 21:10 ProCode-Software

We need a way to reproduce the issue in order to investigate. Thanks!

RyanCavanaugh avatar Oct 09 '24 23:10 RyanCavanaugh

When I select the following code in a javascript file and I refactor it (Move to file -> new file path), I get the issue

async function writeSvgFilesFromData(jsonData) {
    const iconsJson = getIconsJson()

    for (const [name, data] of Object.entries(jsonData)) {
        newIcons.push(name)

        let optimized = optimize(data.icon, svgoConfig).data;

        strokeColors.forEach((color) => {
            optimized = optimized.replaceAll(color, 'currentColor');
        });

        try {
            const fn = rename.kebabCase(name.trim())

            writeFileSync(
                resolve(outDir, `${fn}.svg`),
                optimized
            )
        } catch (e) {
            console.log(ansiColors.red('Error making files:'));
            throw e
        }

        if (name.endsWith(' Variable')) {
            variableIcons.push(name)
        }

        iconsJson[name] = data
    }
    const formatted = await prettierFormat(iconsJson)
    writeFileSync(iconsJsonPath, formatted)
}

What I just realised: Is it just because I'm using functions from my file in the script (e.g. getIconsJson())? I feel like it should automatically do something about it like add an export though.

ProCode-Software avatar Oct 10 '24 02:10 ProCode-Software

@ProCode-Software It sounds like you are entering a file path to a file that is not created yet? (maybe @mjbvz @navya9singh will have more info)

I think only move to new file has the capability to create new files, though you may be able to move it to a new file using the second option below. Since you are using an older version of VSCode, your problem may be fixed if you update your VSCode

Image

iisaduan avatar Oct 24 '24 17:10 iisaduan

Still an issue

mikkelwf avatar Nov 06 '24 09:11 mikkelwf

Easy repro with TS 5.8.3:

  1. Try to move this to a new file https://github.com/microsoft/vscode/blob/2e2ca2d8570891f63e1ca6bac2914a6b3ca1e0e3/src/vs/workbench/contrib/mcp/browser/mcpCommands.ts#L748
  2. Get this error

Server logs:

tsserverlog.zip

connor4312 avatar Jun 10 '25 17:06 connor4312