Skip to content

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

Description

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:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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