diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 81732126c3..3f7a26556d 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5754,21 +5754,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 2d22f41163..584500c101 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9739,9 +9739,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 { @@ -9751,6 +9752,13 @@ declare module _ { isArray(): boolean; } + interface LoDashExplicitWrapperBase { + /** + * @see _.isArray + */ + isArray(): LoDashExplicitWrapper; + } + //_.isBoolean interface LoDashStatic { /**