Skip to content

Commit

Permalink
Revert "Merge: remove extra readonly "
Browse files Browse the repository at this point in the history
  • Loading branch information
Emiyaaaaa authored Jan 23, 2024
1 parent 18a12b7 commit 02891da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
8 changes: 3 additions & 5 deletions source/merge.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {OmitIndexSignature} from './omit-index-signature';
import type {PickIndexSignature} from './pick-index-signature';
import type {Simplify} from './simplify';
import type {EnforceOptional} from './enforce-optional';

// Merges two objects without worrying about index signatures.
type SimpleMerge<Destination, Source> = {
Expand Down Expand Up @@ -41,8 +41,6 @@ export type FooBar = Merge<Foo, Bar>;
@category Object
*/
export type Merge<Destination, Source> =
Simplify<
export type Merge<Destination, Source> = EnforceOptional<
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
>;
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
20 changes: 2 additions & 18 deletions test-d/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ expectType<{
c: undefined;
a?: string;
d?: string;
e: number | undefined;
f: number | undefined;
e?: number;
f?: number;
g: undefined;
}>(fooBarWithOptionalKeys);

Expand Down Expand Up @@ -148,19 +148,3 @@ expectType<{
foo: true;
bar?: any;
}>(sourceWithAny);

// Test for issue https://github.com/sindresorhus/type-fest/issues/601
type Baz = {
t1?: number;
t2?: number;
t3?: number;
t4?: number;
};
declare const baz: Merge<Pick<Baz, 't2' | 't4'>, {
list: string[];
}>;
expectType<{
t2?: number;
t4?: number;
list: string[];
}>(baz);

0 comments on commit 02891da

Please sign in to comment.