TS6198

error TS6198: All destructured elements are unused.

Bad Code ❌

1
2
3
4
5
6
7
8
function returnSomething(): {low: number, high: number} {
return {
low: 10,
high: 20,
};
}

const {low: lowest, high: highest} = returnSomething();

Fixed Code ✔️

You have to make use of the destructured values in your application / code:

1
2
3
4
5
6
7
8
9
10
function returnSomething(): {low: number, high: number} {
return {
low: 10,
high: 20,
};
}

const {low: lowest, high: highest} = returnSomething();

console.log(lowest + highest);