question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
babakkscommented, Jul 27, 2022

@aghArdeshir Because code actions (e.g., “extract function” or “extract constant”) are TypeScript language services which reside in this repository and any invocation at the VS Code side ends up here.

1reaction
aghArdeshircommented, Jul 28, 2022

Thank you very much Babak jan 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm install fails as node-gyp is unable to build lmdb #8152
bug report When trying to install parcel into npm project, npm install --save-dev parcel fails with exit code 7, complaining about node-gyp ...
Read more >
Ask Question - Stack Overflow
This problem can be occur when you are trying to work with an old react repository which is developed with a lower node.js...
Read more >
How to fix "The following module is missing from the file ...
Possible solutions: Restore the module and actually disable and uninstall it (recommended if possible): First, restore the module to its original location in ......
Read more >
How To Work with Files using the fs Module in Node.js
In this article, you will use the fs module to read a file created via the command line, create and write to a...
Read more >
Refactoring source code in Visual Studio Code
When working with classes, you can also extract a value to a new property. ... This keybinding, for example, triggers the Extract function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found