X is Declared, But Never Usedというエラーが出ることがある。
以下のような例だ。
export const onChange = (val: string, index: number) => {
index + 1
}
// val is Declared, But Never Used
回避するには、変数の代わりに空のオブジェクトを使えば良い。
export const onChange = ({}, index: number) => {
index + 1
}
エラーが消えるはずだ。
この方法は可読性を高めてくれるので、気に入った。
完
参考
https://www.triplet.fi/blog/typescript-getting-rid-of-error-x-is-declared-but-never-used/