我正在使用打字稿解构如下:
const props = new Map<User, [Name, Age, Location, Gender]>();
props.set(bill, [n, a, l, g]);
// ...
// Want to access location and gender of bill.
const [n, a, l, g] = props.get(bill);
console.log(l + g);
但这违反了noUnusedLocals
编译器选项,所以我真正想要的是:
const [_, _, l, g] = props.get(bill);
但这违反了对块范围变量(两个名为 的变量_
)的重新声明。
处理这个问题的最佳方法是什么?也许解构在这里只是错误的选择。