lodash: fix flattenDeep to correctly handle strings (#38625)

* lodash: fix flattenDeep to correctly handle strings

* fix whitespace
This commit is contained in:
Robert Stocks 2019-09-27 00:06:08 +01:00 committed by Michael Crane
parent 50fab9758a
commit a9c67da719
2 changed files with 6 additions and 1 deletions

View File

@ -488,7 +488,9 @@ declare module "../index" {
*/
flatten(): T extends Many<infer U> ? CollectionChain<U> : CollectionChain<T>;
}
type Flat<T> = (T extends List<any> ? never : T);
type Flat<T> = T extends string ? T : (T extends List<any> ? never : T);
interface LoDashStatic {
/**
* Recursively flattens a nested array.

View File

@ -497,6 +497,9 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>
_.flattenDeep([1, [2, [3, [4, 5]]]]); // $ExpectType number[]
_.flattenDeep({0: 1, 1: [2, [3, [4, 5]]], length: 2}); // $ExpectType number[]
_.flattenDeep(['x']); // $ExpectType string[]
_.flattenDeep(['x', ['y']]); // $ExpectType string[]
_.flattenDeep<number>([1, 2, 3]); // $ExpectType number[]
_.flattenDeep<number>([[1, 2, 3]]); // $ExpectType number[]
_.flattenDeep<number>([1, [2, [3, [4, 5]]]]); // $ExpectType number[]