Skip to content

Commit 43f77dd

Browse files
committed
fix: SimplifyDeep should not skip arrays
1 parent fa55f48 commit 43f77dd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

source/simplify-deep.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {ConditionalSimplifyDeep} from './conditional-simplify-deep.d.ts';
22
import type {MapsSetsOrArrays, NonRecursiveType} from './internal/index.d.ts';
3+
import type {UnknownArray} from './unknown-array.d.ts';
34

45
/**
56
Deeply simplifies an object type.
@@ -109,7 +110,7 @@ type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2, ComplexTyp
109110
export type SimplifyDeep<Type, ExcludeType = never> =
110111
ConditionalSimplifyDeep<
111112
Type,
112-
ExcludeType | NonRecursiveType | MapsSetsOrArrays,
113+
ExcludeType | NonRecursiveType | Exclude<MapsSetsOrArrays, UnknownArray>,
113114
object
114115
>;
115116

test-d/simplify-deep.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,15 @@ declare const flattenProperties2: {
4242
}>;
4343
};
4444
expectType<SimplifyDeep<{arrayType: ArrayType}>>(flattenProperties2);
45+
46+
declare function testArraySimplification(arg: {foo: Array<{[x: string]: string}>}): void;
47+
48+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
49+
interface BarBaz {
50+
bar: string;
51+
baz: string;
52+
}
53+
54+
// This would fail if `SimplifyDeep` did not simplify arrays,
55+
// because interfaces being open are not compatible with index signatures.
56+
testArraySimplification({} as SimplifyDeep<{foo: BarBaz[]}>);

0 commit comments

Comments
 (0)