diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 8822deca98..72498e3591 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1,13 +1,13 @@ // Type definitions for Underscore 1.8 // Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman +// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman , Ard Timmerman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } @@ -3631,7 +3631,7 @@ declare module _ { * @param object Convert this object to a list of [key, value] pairs. * @return List of [key, value] pairs on `object`. **/ - pairs(object: any): any[][]; + pairs(object: any): [string, any][]; /** * Returns a copy of the object where the keys have become the values and the values the keys. @@ -4738,7 +4738,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): any[][]; + pairs(): [string, any][]; /** * Wrapped type `object`. @@ -5692,7 +5692,7 @@ declare module _ { * Wrapped type `object`. * @see _.values **/ - values(): _Chain; + values(): _Chain; /** * Wrapped type `object`. @@ -5704,7 +5704,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): _Chain; + pairs(): _Chain<[string, any]>; /** * Wrapped type `object`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 419479f689..6175c1874b 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -527,6 +527,16 @@ function chain_tests() { .keys() // return ['foo', 'bar'] : string[] .pairs() // return [['foo', '0'], ['bar', '1']] : string[][] .value(); + + interface IYears { + 2016: number; + 2017: number; + } + + let yearObject: IYears = {2016: 1, 2017: 2}; + let valuePerYear: number[] = _.chain(yearObject) + .values() + .value() } var obj: { [k: string] : number } = {