I'm trying to determine if this is, in fact, a bug before entering anything on GitHub.
With noUnusedParameters
enabled, the TypeScript compiler will error on something like:
const foo = ['one', 'two', 'three'];
foo.forEach((item: string, index: number) => {
// do something just with index, ignoring item
});
with error TS6133: 'item' is declared but never used.
But while it's not specifically used, it is being used in that the second argument to the forEach
iterator function is the index.
Am I missing something?
There's no need to file an issue, as one already exists: with --noUnusedParameters how can i skip uneeded parameters.
tl;dr:
You can skip this error by prefixing the uninteresting arguments with underscore:
const foo = ['one', 'two', 'three'];
foo.forEach((_item: string, index: number) => {
console.log(index);
});
Compiles fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With