Merge pull request #33483 from DefinitelyTyped/revert-33095-patch-2

Revert "[underscore] Deduce return type from key in _.pluck"
This commit is contained in:
Jesse Trinity
2019-02-28 13:48:35 -08:00
committed by GitHub
4 changed files with 8 additions and 7 deletions
+5 -2
View File
@@ -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
-1
View File
@@ -2,7 +2,6 @@
// Project: https://github.com/epeli/underscore.string
// Definitions by: Ry Racherbaumer <https://github.com/rygine>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import * as _ from 'underscore';
+2 -3
View File
@@ -2,7 +2,6 @@
// Project: http://underscorejs.org/
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Josh Baldwin <https://github.com/jbaldwin>, Christopher Currens <https://github.com/ccurrens>, Cassey Lottman <https://github.com/clottman>, Ard Timmerman <https://github.com/confususs>
// 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<T extends {}, K extends keyof T>(
pluck<T extends {}>(
list: _.List<T>,
propertyName: K): T[K][];
propertyName: string): any[];
/**
* Returns the maximum value in list.
+1 -1
View File
@@ -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'})