Skip to content

Bug report: Comment node is removed after "Extract to function in module scope #49784

Closed
@aghArdeshir

Description

@aghArdeshir

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

  • VS Code Version: 1.68.1
  • OS Version: Ubuntu 22.04

NOTE: I couldn't find this option in VSCode Insiders! (Maybe it is removed)

Hi. When I refactor a callback in my JSX, which does something rather complicated, one of my comments are removed.

Code example:

//@ts-nocheck
/* eslint-disable */

export default function Something() {
  return (
    <SomeComponent
      aCallbackThatProducesAReactNode={() => {
        // this comment will be kept intact
        const someProps = {
          prop1: props.props1, // BUT THIS COMMENT WILL BE REMOVED :(

          prop2: props.props2 // this comment will be kept intact too
        };

        return <SomeOtherComponent {...someProps} />;
      }}
    />
  );
}

Try refactoring the whole callback into a function in module scope.

One:
image

Two:
image

Three:
image

As you see one of my comments are removed.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: 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