Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Move to a new file" refactor was recently broken for some import names #60408

Closed
CGNonofr opened this issue Nov 4, 2024 · 1 comment Β· Fixed by #60450
Closed

"Move to a new file" refactor was recently broken for some import names #60408

CGNonofr opened this issue Nov 4, 2024 · 1 comment Β· Fixed by #60450
Labels
Fix Available A PR has been opened for this issue

Comments

@CGNonofr
Copy link

CGNonofr commented Nov 4, 2024

πŸ”Ž Search Terms

refactor, move to new file

πŸ•— Version & Regression Information

⏯ Playground Link

No response

πŸ’» Code

  • test1.ts:
import Event from './test2.js';

export function test(test: Event): void {
	console.log(test);
}
  • test2.ts
export default class Event {
}

then tries to "move to new file" the test function from test1.ts

πŸ™ Actual behavior

the function is moved to a new file, but not the import so Event is not resolved in the new file

πŸ™‚ Expected behavior

the whole content of the test1.ts file is moved to a new file (with the import)

Additional information about the issue

It looks like it has something to do with the name, as if it's imported as something else than Event there is no issue

@Andarist
Copy link
Contributor

Andarist commented Nov 4, 2024

Failing test case:

/// <reference path='fourslash.ts' />

// @lib: dom

// @Filename: /a.ts
//// export default class Event {}

// @Filename: /b.ts
//// import Event from './a.js';
//// [|export function test(test: Event): void {}|]

verify.noErrors();

verify.moveToNewFile({
    newFileContents: {
        "/b.ts": "",

        "/test.ts":
`import Event from './a';

export function test(test: Event): void { }
`,
    },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue
Projects
None yet
3 participants