From 311f0b973efdcde51cef6610ec9702cafbfef38b Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 23 Dec 2015 03:23:58 +0500 Subject: [PATCH] lodash: signatures of _.isArray have been changed --- lodash/lodash-tests.ts | 48 +++++++++++++++++++++++++++++------------- lodash/lodash.d.ts | 12 +++++++++-- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d661839d54..bbf8060138 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5395,21 +5395,39 @@ result = _({}).isArguments(); } // _.isArray -result = _.isArray(any); -result = _(1).isArray(); -result = _([]).isArray(); -result = _({}).isArray(); -{ - let value: number[]|string = [1, 3, 5]; - if (_.isArray(value)) { - let length: number[] = value.concat(4); - // compile error - // let char: string = value.charAt(0); - } else { - let char: string = value.charAt(0); - // compile error - // let length: number[] = value.concat(4); - } +module TestIsArray { + { + let value: number|string[]|boolean[]; + + if (_.isArray(value)) { + let result: string[] = value; + } + else { + if (_.isArray(value)) { + let result: boolean[] = value; + } + else { + let result: number = value; + } + } + } + + { + let result: boolean; + + result = _.isArray(any); + result = _(1).isArray(); + result = _([]).isArray(); + result = _({}).isArray(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isArray(); + result = _([]).chain().isArray(); + result = _({}).chain().isArray(); + } } // _.isBoolean diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 4e86afb66b..cd9a7a1fc9 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9243,9 +9243,10 @@ declare module _ { /** * Checks if value is classified as an Array object. * @param value The value to check. + * * @return Returns true if value is correctly classified, else false. - **/ - isArray(value?: any): value is any[]; + */ + isArray(value?: any): value is T[]; } interface LoDashImplicitWrapperBase { @@ -9255,6 +9256,13 @@ declare module _ { isArray(): boolean; } + interface LoDashExplicitWrapperBase { + /** + * @see _.isArray + */ + isArray(): LoDashExplicitWrapper; + } + //_.isBoolean interface LoDashStatic { /**