score:-1

The adjust is simpler than it, the problem is your variable is "array: Array<MyArray>", and "sort" return "array: MyArray[]", so, just change your variable to "array: MyArray[]".

score:14

I just encountered this issue with a function that simply clones and sorts an array, e.g.

const sortArray = (myArr: MyArray[]) => [...myArr].sort((a, b) => a > b ? -1 : 1)

What solved it for me was simply typing the return value of sortArray:

const sortArray = (myArr: MyArray[]): MyArray[] => [...myArr].sort((a, b) => a > b ? -1 : 1)

Related Query

More Query from same tag