Skip to content

variable is declared but its value is never read when destructing array #31357

Closed
@jerrygreen

Description

@jerrygreen

When destructing array, I want some variables/const to be declared but explicitly make them unused. Typescript has a feature of underscoring the unused parameters for functions:

const f = (a, _b) => a`)

But it doesn't work for array destruction:

const [a, _b] = [1, 2]

TypeScript Version: 3.5.0-dev.20190512

Search Terms:

  • declared but never used noUnusedLocals

Code

const [a, _b] = [1, 2]
export default a

Expected behavior:

No error

Actual behavior:

Got an error, '_b' is declared but its value is never read:

Playground Link:

Here's it, OR use my gist:

git clone git@gist.github.com:240a015b7833fd6628c5c8ccfaa7938e.git test-ts-unused
cd test-ts-unused
tsc

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions