mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
lodash: fix flattenDeep to correctly handle strings (#38625)
* lodash: fix flattenDeep to correctly handle strings * fix whitespace
This commit is contained in:
parent
50fab9758a
commit
a9c67da719
4
types/lodash/ts3.1/common/array.d.ts
vendored
4
types/lodash/ts3.1/common/array.d.ts
vendored
@ -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.
|
||||
|
||||
@ -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[]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user