From 6fbf63ce7cc02ae165460250696b4131fec9630f Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Mon, 13 May 2019 18:54:39 +0200 Subject: [PATCH] Underscore: fix _.map IterateePropertyShorthand overload (#35181) * Fix a type overload * Add matching test * Re-enable underscore linter rules that weren't violated * Add myself to the list of underscore contributors --- types/underscore/index.d.ts | 9 ++++-- types/underscore/tslint.json | 46 ---------------------------- types/underscore/underscore-tests.ts | 1 + 3 files changed, 8 insertions(+), 48 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index e3973187c8..c7ab92e0ae 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1,6 +1,11 @@ // Type definitions for Underscore 1.8 // Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman , Ard Timmerman +// Definitions by: Boris Yankov +// Josh Baldwin +// Christopher Currens +// Cassey Lottman +// Ard Timmerman +// Julian Gonggrijp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -171,7 +176,7 @@ declare module _ { map( list: _.List, iterator: _.IterateePropertyShorthand, - context?: any): T[]; + context?: any): any[]; map( list: _.List, diff --git a/types/underscore/tslint.json b/types/underscore/tslint.json index 3d59f55fda..73a1d7527a 100644 --- a/types/underscore/tslint.json +++ b/types/underscore/tslint.json @@ -1,80 +1,34 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, "array-type": false, "arrow-return-shorthand": false, "ban-types": false, - "callable-types": false, "comment-format": false, - "dt-header": false, - "npm-naming": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, "interface-name": false, - "interface-over-type-literal": false, "jsdoc-format": false, "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, "no-namespace": false, - "no-object-literal-type-assertion": false, "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, "no-unnecessary-generics": false, "no-unnecessary-qualifier": false, "no-unnecessary-type-assertion": false, - "no-useless-files": false, "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, "object-literal-key-quotes": false, "object-literal-shorthand": false, - "one-line": false, "one-variable-per-declaration": false, "only-arrow-functions": false, - "prefer-conditional-expression": false, "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, "prefer-template": false, - "radix": false, "semicolon": false, "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, "trim-file": false, "triple-equals": false, "typedef-whitespace": false, "unified-signatures": false, - "void-return": false, "whitespace": false } } diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 4396ce5c35..e81b848414 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -9,6 +9,7 @@ _.each({ one: 1, two: 2, three: 3 }, (value, key) => alert(value.toString())); _.map([1, 2, 3], (num) => num * 3); _.map({ one: 1, two: 2, three: 3 }, (value, key) => value * 3); +let plucked: string[] = _.map([{key: 'apples'}, {key: 'oranges'}], 'key'); //var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0); // https://typescript.codeplex.com/workitem/1960 var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0);