Skip to content

Refactor: move to new file does not work #59650

Closed

Description

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: Version: 1.92.1 (Universal)
  • OS Version: MacOS Sonoma 14.5 / Apple M1 Pro

Steps to Reproduce:

  1. Refactor > move to new file

What I tried already:

  1. Run with --disable-extensions to ensure it's not a problem with a package.
  2. typescript.tsserver.enableTrace
  3. find minimal examples
  4. search for similar issues: Refactor: move to new file does not work vscode#51586, Refactor > Move to a new file -- not working (update, nothing in Refactor menu working) vscode#58711

It worked a few versions before. I don't know exactly what version was okay.

UPD: not working:

import { useLatest } from 'react-use';

export function useUseLatest (data: string) {
    return useLatest(data);
}

not working:

import { selectStore, useSelector } from '@proterm/core';

export function useOrders() {
    return useSelector(selectStore);
}

not working:

import { selectStore } from '@proterm/core';

export function useOrders() {
    return selectStore;
}

working:

import { AnyBaseOrder } from '@terminal/scalp/types';

export function useOrders(symbolId: string): AnyBaseOrder[] {}

working:

import { useSelector } from 'react-redux';

function useOrders() {
    return useSelector((state) => console.log(state));
}

working:

import { selectStore, useSelector } from '@proterm/core';
export function useOrders(symbolId: string): AnyBaseOrder[] {}

I though @ import aliases is a problem, however this works too:

import { FancyAlertCircleIcon } from '@terminal/icons';

export function useOrders() {
    return FancyAlertCircleIcon;
}

error:

2024-08-15 18:42:15.101 [error] <semantic> TypeScript Server Error (5.5.4)
Debug Failure.
Error: Debug Failure.
    at Object.addImportFromExportedSymbol (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:154243:32)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:144288:19
    at Map.forEach (<anonymous>)
    at addTargetFileImports (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:144282:17)
    at getNewStatementsAndRemoveFromOldFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:143512:3)
    at doChange4 (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:144488:3)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:144477:77
    at _ChangeTracker.with (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:174306:5)
    at Object.getRefactorEditsToMoveToNewFile [as getEditsForAction] (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:144477:60)
    at Object.getEditsForRefactor (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:142603:31)
    at Object.getEditsForRefactor2 [as getEditsForRefactor] (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:149939:32)
    at IpcIOSession.getEditsForRefactor (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:191087:49)
    at getEditsForRefactor (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:189305:43)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:191491:69
    at IpcIOSession.executeWithRequestId (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:191483:14)
    at IpcIOSession.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:191491:29)
    at IpcIOSession.onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js:191533:51)
    at process.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:523: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): Error: <semantic> TypeScript Server Error (5.5.4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions