Skip to content

codefix: Remove declaration for local in destructuring assignment breaks code. #22330

Closed
@NaridaL

Description

@NaridaL

TypeScript Version: 2.8.0-dev.20180302

Search Terms: "remove declaration for" remove declaration destructuring

Code

--noUnusedLocals needs to be on.
The "remove declaration for" quick fix for unused locals is broken:

function f() {
	const {abs, floor, ceil} = Math
	const {sin, cos, tan} = Math
}

Expected behavior:
After code fix on abs:

function f() {
	const {floor, ceil} = Math
	const {sin, cos, tan} = Math
}

After code fix "fix all":

function f() {
}

Possible side effects of the RHS are ignored by the const abs = Math.abs quick fix, so this should be mirrored here.
Actual behavior:

function f() {
	const {, floor, ceil} = Math
	const {sin, cos, tan} = Math
}

After code fix "fix all":

function f() {
	const {,,} = Math
	const {,,} = Math
}

screencast: https://gfycat.com/SleepyEnchantingArcticfox

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions