Skip to content

"Delete all unused Declarations" removed necessary parameters from callbacks #25401

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

Closed
bcrobinson opened this issue Jul 3, 2018 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@bcrobinson
Copy link

bcrobinson commented Jul 3, 2018

TypeScript Version: 2.9.2 (also confirmed 3.0.0-dev.20180703)
Issue Type : Bug

Search Terms:
Refactor
Delete all unused Declarations
fixUnusedIdentifier

Code
When running the remove unused declarations refactor in VSCode it will remove unused parameters from any callbacks even when they are not the last position, which causes code to behave differently.

Initial code

import * as Q from 'q';

let items = ["a", "b", "c"];

items.map((c, i) => i);

Actual Code after refactor
After running "Delete all unused Declarations" refactor on the unused import line ends up with:

let items = ["a", "b", "c"];

items.map((i) => i);

The refactor removed he "c" parameter, which changed the behaviour of the code.

Expected behaviour:
Expected the unused "c" parameter to be left alone (or replaced in "_", just not removed).

let items = ["a", "b", "c"];

items.map((c, i) => i);

Related Issues:
Something similar was mentioned in #24789 (comment) @Andy-MS seems to have done a change in #25011 related to that comment, but from what I can tell that seems to be for also removing the unused parameters from the function body instead.

@ghost
Copy link

ghost commented Jul 3, 2018

Doesn't reproduce for me with [email protected]. (Does reproduce with [email protected].) Are you sure your editor is set up to use the locally installed typescript?

@ghost ghost added the Needs More Info The issue still hasn't been fully clarified label Jul 3, 2018
@bcrobinson
Copy link
Author

Yes it seems that VSCode was still using v2.9.2.
I've tested this in a brand new project and confirmed that it's fixed in the latest daily build ([email protected]).

@ghost ghost added Duplicate An existing issue was already created and removed Needs More Info The issue still hasn't been fully clarified labels Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

1 participant