Skip to content

Refacoring "Convert named export to default" removes function typeings #39410

Closed
@essenmitsosse

Description

@essenmitsosse

TS Template added by @mjbvz

TypeScript Version: 4.0.0-dev.20200702

Search Terms

  • refactor / refactoring

  • VSCode Version: 1.46.1
  • OS Version: MacOS 10.15.5

Steps to Reproduce:

  1. Have a file with a named export, that is typed like this:
export const getFoo: (input: number) => number = (input) => input;
  1. Click "Convert named export to default" in the refactoring menu

  2. The refactored code new lacks the typing

export default (input) => input;

I would expect the refactoring to maintain the functions typing. For example like this:

const getFoo: (input: number) => number = (input) => input;
export default getFoo;

After all, the intend of the refactoring is to change the type of the export, not the way the code is written. I mainly use this refactoring, to automatically change the imports in other files. So for me, just removing the export before const and add a new line with export default getFoo would be sufficient for this refactoring.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbol

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions