I got this code:
const reducer = (element:number, index: number) => [element]; //es lint error.
const positionsArray = $.map(this.positions, reducer);
I am casting a Float32Array (it is this.positions) to a js array. I get the error: 'index' is defined but never used.eslint@typescript-eslint/no-unused-vars
I cannot apply the "// eslint-disable-line no-unused-vars" (which btw I dont think is a pleasant solution)
How to get rid of this error for this case that I don't need the index? I checked reduce and try to retrieve the accumulator but did not achieve it. Thanks.
Don't define the parameter. Neither TypeScript nor JavaScript requires you to use all parameters that a callback might accept.
You can also convert the typed array to a normal array by invoking the iterator - it looks like jQuery's
.map
doesn't behave well with it, so use plain JS instead:If you just want to get a plain array from the typed array, don't use
.map
, just invoke the iterator alone: