From 70159acd84e0c8c153532c51f0143223ec2a3c32 Mon Sep 17 00:00:00 2001 From: Jesse Trinity <42591254+jessetrinity@users.noreply.github.com> Date: Thu, 28 Feb 2019 13:08:12 -0800 Subject: [PATCH] Revert "[underscore] Deduce return type from key in _.pluck" --- types/icepick/icepick-tests.ts | 7 +++++-- types/underscore.string/index.d.ts | 1 - types/underscore/index.d.ts | 5 ++--- types/underscore/underscore-tests.ts | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/types/icepick/icepick-tests.ts b/types/icepick/icepick-tests.ts index f1d536e78f..5458509d42 100644 --- a/types/icepick/icepick-tests.ts +++ b/types/icepick/icepick-tests.ts @@ -1,4 +1,5 @@ import i = require("icepick"); +import * as _ from 'underscore'; "use strict"; // so attempted modifications of frozen objects will throw errors @@ -145,13 +146,15 @@ class Foo {} { i.map(function(v) { return v * 2 }, [1, 2, 3]); // [2, 4, 6] - i.filter(function(v: number) { return v % 2 === 0; }, [1, 2, 3]); // [1, 3] + var removeEvens = _.partial(i.filter, function(v: number) { return v % 2; }); + + removeEvens([1, 2, 3]); // [1, 3] } { var arr = i.freeze([{ a: 1 }, { b: 2 }]); //ECMAScript 2015 - //arr.find(function(item) { return item.b != null; }); // {b: 2} + //arr.find(function(item) { return item.b != null; }); // {b: 2} } // chain(coll) - not defined diff --git a/types/underscore.string/index.d.ts b/types/underscore.string/index.d.ts index ce2e46edd1..eb0774b49a 100644 --- a/types/underscore.string/index.d.ts +++ b/types/underscore.string/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/epeli/underscore.string // Definitions by: Ry Racherbaumer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 import * as _ from 'underscore'; diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 8222ecbb74..72498e3591 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -2,7 +2,6 @@ // Project: http://underscorejs.org/ // Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman , Ard Timmerman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 declare var _: _.UnderscoreStatic; export = _; @@ -554,9 +553,9 @@ declare module _ { * @param propertyName The property to look for on each element within `list`. * @return The list of elements within `list` that have the property `propertyName`. **/ - pluck( + pluck( list: _.List, - propertyName: K): T[K][]; + propertyName: string): any[]; /** * Returns the maximum value in list. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index c6086fe5c0..6175c1874b 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -520,7 +520,7 @@ function chain_tests() { let numberObjects = [{property: 'odd', value: 1}, {property: 'even', value: 2}, {property: 'even', value: 0}]; let evenAndOddGroupedNumbers = _.chain(numberObjects) .groupBy('property') - .mapObject((objects) => _.pluck(objects, 'value')) + .mapObject((objects: any) => _.pluck(objects, 'value')) .value(); // { odd: [1], even: [0, 2] } var matrixOfString : string[][] = _.chain({'foo' : '1', 'bar': '1'})