I'm destructuring the result of a regex match
function getStuffIWant(str: string): string {
const [
fullMatch, // [ts] 'fullMatch' is declared but its value is never read.
stuffIWant,
] = str.match(/1(.*)2/);
return stuffIWant;
}
getStuffIWant("abc1def2ghi");
As the comment points out, fullMatch
is never used and TSC wants me to know. Is there any way to suppress this error without turning off unused checks across the board?
I've also tried unpacking the array as an object:
const {
1: stuffIWant, // Unexpected SyntaxError: Unexpected token :
} = str.match(/1(.*)2/);