From edd18c02adb0b195cfe954d3eb942cef0a76e97d Mon Sep 17 00:00:00 2001 From: Bob Thomas Date: Wed, 3 Jun 2020 13:32:26 -0400 Subject: [PATCH] Add separate type for options passed to custom functions Before the options are passed to custom functions, they are set to default values and have an additional "cloneUnlessOtherwiseSpecified" function added. This adds a separate type for the required/default options with the additional function. --- index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 7412fcf..86dfede 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,10 +2,13 @@ declare function deepmerge(x: Partial, y: Partial, options?: deepmerge. declare function deepmerge(x: Partial, y: Partial, options?: deepmerge.Options): T1 & T2; declare namespace deepmerge { + export type CustomOptions = Required & { + cloneUnlessOtherwiseSpecified: (item: any, options: CustomOptions) => any + } export interface Options { - arrayMerge?(target: any[], source: any[], options?: Options): any[]; + arrayMerge?(target: any[], source: any[], options: CustomOptions): any[]; clone?: boolean; - customMerge?: (key: string, options?: Options) => ((x: any, y: any) => any) | undefined; + customMerge?: (key: string, options: CustomOptions) => ((x: any, y: any) => any) | undefined; isMergeableObject?(value: object): boolean; }