Sha256: 6927ceeb41bb451f47593de0180c8ff1be7403965d10dc9147ee8d5c91372fff

Contents?: true

Size: 1.09 KB

Versions: 28

Compression:

Stored size: 1.09 KB

Contents

import type {OmitIndexSignature} from './omit-index-signature';
import type {PickIndexSignature} from './pick-index-signature';
import type {Simplify} from './simplify';

// Merges two objects without worrying about index signatures.
type SimpleMerge<Destination, Source> = {
	[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
} & Source;

/**
Merge two types into a new type. Keys of the second type overrides keys of the first type.

@example
```
import type {Merge} from 'type-fest';

interface Foo {
	[x: string]: unknown;
	[x: number]: unknown;
	foo: string;
	bar: symbol;
}

type Bar = {
	[x: number]: number;
	[x: symbol]: unknown;
	bar: Date;
	baz: boolean;
};

export type FooBar = Merge<Foo, Bar>;
// => {
// 	[x: string]: unknown;
// 	[x: number]: number;
// 	[x: symbol]: unknown;
// 	foo: string;
// 	bar: Date;
// 	baz: boolean;
// }
```

@category Object
*/
export type Merge<Destination, Source> =
Simplify<
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
>;

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/type-fest/source/merge.d.ts