diff --git a/types/lodash/ts3.1/common/array.d.ts b/types/lodash/ts3.1/common/array.d.ts index 73e4e642c2..3831ba97ce 100644 --- a/types/lodash/ts3.1/common/array.d.ts +++ b/types/lodash/ts3.1/common/array.d.ts @@ -488,7 +488,9 @@ declare module "../index" { */ flatten(): T extends Many ? CollectionChain : CollectionChain; } - type Flat = (T extends List ? never : T); + + type Flat = T extends string ? T : (T extends List ? never : T); + interface LoDashStatic { /** * Recursively flattens a nested array. diff --git a/types/lodash/ts3.1/lodash-tests.ts b/types/lodash/ts3.1/lodash-tests.ts index 339f1f2c3e..927a8fae8c 100644 --- a/types/lodash/ts3.1/lodash-tests.ts +++ b/types/lodash/ts3.1/lodash-tests.ts @@ -497,6 +497,9 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain _.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([1, 2, 3]); // $ExpectType number[] _.flattenDeep([[1, 2, 3]]); // $ExpectType number[] _.flattenDeep([1, [2, [3, [4, 5]]]]); // $ExpectType number[]