TypeScript refinement of the compiler option noUnusedParameters

I am trying to determine if this is really a bug before contributing anything to GitHub.

When enabled noUnusedParameters, the TypeScript compiler will fail on something like:

const foo = ['one', 'two', 'three'];
foo.forEach((item: string, index: number) => {
  // do something just with index, ignoring item
});

c error TS6133: 'item' is declared but never used.But while it is not specifically used, it is used in that the second argument to the forEachiterator function is the index.

Did I miss something?

+6
source share
1 answer

There is no need to register a problem since it already exists: with --noUnusedParameters, how can I skip parameters without parameters .

; :
, :

const foo = ['one', 'two', 'three'];
foo.forEach((_item: string, index: number) => {
    console.log(index);
});

.

+9

Source: https://habr.com/ru/post/1014134/


All Articles