Skip to content

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

@bcrobinson

Description

@bcrobinson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions