jashkenas / underscore

JavaScript's utility _ belt
https://underscorejs.org
MIT License
27.33k stars 5.53k forks source link

Chain sorting an array does not return an array (Typescript) #2812

Closed MichaelGatesDev closed 4 years ago

MichaelGatesDev commented 5 years ago

This snippet worked for me until I added Typescript and updated the package

rooms = _(this.getAllRooms()).chain().sortBy(function (room: Room) {
                return room.number;
            }, this).sortBy(function (room: Room) {
                return room.buildingName;
            }, this).value();

Code here

It takes an array of objects, sorts them, and returns the sorted array.

But now, it complains that this code does not return a Room[] or otherwise array of objects. Rather, it returns a single Room. Using values returns a _._Chain<any, any> which is also not what I need.

How can I get around this issue? I just need a standard array returned.

MichaelGatesDev commented 5 years ago

It appears this issue is likely also this issue

jgonggrijp commented 4 years ago

This is certainly an issue with @types/underscore rather than with underscore itself.

jgonggrijp commented 4 years ago

Closing. Please feel free to comment or reopen.