-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 3.1.0-dev.20180809
Search Terms:
noUnusedLocals
destructuring assignment
declared but its value is never read
Code
// Compile with --noUnusedLocals
{
const abc = 1 // 'abc' is declared but its value is never read.
let def: number // 'def' is declared but its value is never read.
def = 2
}
{
const {abc} = {abc: 1} // 'abc' is declared but its value is never read.
let def: number // no compiler error
({def} = {def: 2})
}
{
const [abc] = [1] // 'abc' is declared but its value is never read.
let def: number // no compiler error
[def] = [2]
}
Expected behavior:
All 6 variable declarations should cause a compiler error because they are declared but never read. It should not matter whether the variable is assigned to where it is declared, or afterwards.
Actual behavior:
Destructuring assignments to variables after they are declared marks them as read, even though they are only written to. Direct assignments work as expected.
Playground Link:
N/A; playground doesn't support noUnusedLocals
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue