Skip to content

Refactoring 'Move to file' imports undefined from source file #60783

Closed
@aramikuto

Description

@aramikuto

πŸ”Ž Search Terms

"move to file imports undefined", "refactor", "move to a new file imports undefined"

πŸ•— Version & Regression Information

This changed between versions 5.7.1-rc and 5.7.2

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBAYwgOwM7wG4EMoEssBGANsHALxwCuyAJsAGa7LA0DcQA

πŸ’» Code

export const variable = undefined;

πŸ™ Actual behavior

When applying the Move to file or Move to a new file refactoring, the resulting file incorrectly imports an undefined value from the original module.

For example, if the original file is named orig.ts, the refactored file will output

import { undefined } from "./orig";

export const variable = undefined;

πŸ™‚ Expected behavior

undefined is an internal type and should not be imported. The correct output should be:

export const variable = undefined;

Additional information about the issue

No response

Activity

aramikuto

aramikuto commented on Dec 18, 2024

@aramikuto
Author

I performed a bisect, and it seems that this issue was most likely introduced in #60450

added this to the TypeScript 5.8.0 milestone on Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

    Participants

    @andrewbranch@RyanCavanaugh@aramikuto

    Issue actions

      Refactoring 'Move to file' imports undefined from source file Β· Issue #60783 Β· microsoft/TypeScript