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

Convert to destructed refactoring not enabled in JavaScript? #30764

Open
mjbvz opened this issue Apr 5, 2019 · 1 comment
Open

Convert to destructed refactoring not enabled in JavaScript? #30764

mjbvz opened this issue Apr 5, 2019 · 1 comment
Labels
Domain: JavaScript The issue relates to JavaScript specifically Domain: Refactorings e.g. extract to constant or function, rename symbol In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Apr 5, 2019

TypeScript Version: 3.5.0-dev.20190404

Search Terms:

  • refactor / refactoring
  • convert to destructed parameters

Code
For a simple js file

function doStuff(a, b, c) {
    return a + b + c;
}

doStuff('a', 'b', 1);
doStuff('x', 'y', 2);

Expected behavior:
A convert to restructured refactoring is available on doStuff

Actual behavior:
I'm not seeing any such refactoring show up in js files

Playground Link:

Related Issues:

mjbvz added a commit to microsoft/vscode-docs that referenced this issue Apr 5, 2019
With 3.4.1, I'm not able to get it working in even simple js cases, see: microsoft/TypeScript#30764
@DanielRosenwasser DanielRosenwasser added Domain: Refactorings e.g. extract to constant or function, rename symbol In Discussion Not yet reached consensus Suggestion An idea for TypeScript Domain: JavaScript The issue relates to JavaScript specifically labels Apr 5, 2019
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Apr 5, 2019

In #29694 and #30089, we decided that due to the lack of type information, JS refactorings were disabled if the declarations were untyped. For some motivation, I've had the chance of speaking with developers who had aversions to any refactorings in which a failed refactor couldn't be caught by the type checker. The hazards are worse in JS code which is untyped.

This is weird, since the same limitation isn't present for the same TypeScript code (which is also fully untyped in the parameters list.

We also don't surface the refactoring for JSDoc'd code either.

@sandersn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: JavaScript The issue relates to JavaScript specifically Domain: Refactorings e.g. extract to constant or function, rename symbol In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants