Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion source/simplify-deep.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {ConditionalSimplifyDeep} from './conditional-simplify-deep.d.ts';
import type {MapsSetsOrArrays, NonRecursiveType} from './internal/index.d.ts';
import type {UnknownArray} from './unknown-array.d.ts';

/**
Deeply simplifies an object type.
Expand Down Expand Up @@ -109,7 +110,7 @@ type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2, ComplexTyp
export type SimplifyDeep<Type, ExcludeType = never> =
ConditionalSimplifyDeep<
Type,
ExcludeType | NonRecursiveType | MapsSetsOrArrays,
ExcludeType | NonRecursiveType | Exclude<MapsSetsOrArrays, UnknownArray>,
object
>;

Expand Down
19 changes: 10 additions & 9 deletions test-d/simplify-deep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ declare const flattenProperties: {
expectType<SimplifyDeep<Properties1 & Properties2>>(flattenProperties);

// Array
type ArrayType = Array<{
a: string;
}>;
declare function testArraySimplification(arg: {foo: Array<{[x: string]: string}>}): void;

declare const flattenProperties2: {
arrayType: Array<{
a: string;
}>;
};
expectType<SimplifyDeep<{arrayType: ArrayType}>>(flattenProperties2);
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface BarBaz {
bar: string;
baz: string;
}

// This would fail if `SimplifyDeep` did not simplify arrays,
// because interfaces being open are not compatible with index signatures.
testArraySimplification({} as SimplifyDeep<{foo: BarBaz[]}>);