From ed6205be577438a76ba26c47d6c636bdbcf3d027 Mon Sep 17 00:00:00 2001 From: Jesse Katsumata Date: Tue, 10 Sep 2019 14:52:15 +0900 Subject: [PATCH] [#683] Convert merge.js to typescript (#687) * chore: rename merge.js to merge.ts (#683) * chore: add type to deepmerge(#683) * chore: add FlowFixMe temporarily for files converted to TS (#683) * chore: add underscore in arg for unused param --- packages/cli/src/tools/config/index.js | 1 + packages/cli/src/tools/merge.js | 15 --------------- packages/cli/src/tools/merge.ts | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 15 deletions(-) delete mode 100644 packages/cli/src/tools/merge.js create mode 100644 packages/cli/src/tools/merge.ts diff --git a/packages/cli/src/tools/config/index.js b/packages/cli/src/tools/config/index.js index 08afb4e72..eda09c404 100644 --- a/packages/cli/src/tools/config/index.js +++ b/packages/cli/src/tools/config/index.js @@ -20,6 +20,7 @@ import type { DependencyConfigT, } from 'types'; import assign from '../assign'; +// $FlowFixMe - converted to TS import merge from '../merge'; import resolveNodeModuleDir from './resolveNodeModuleDir'; diff --git a/packages/cli/src/tools/merge.js b/packages/cli/src/tools/merge.js deleted file mode 100644 index 4439b50cc..000000000 --- a/packages/cli/src/tools/merge.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @flow - */ - -import deepmerge from 'deepmerge'; - -/** - * `deepmerge` concatenates arrays by default instead of overwriting them. - * We define custom merging function for arrays to change that behaviour - */ -export default function merge(...objs: Array<{[key: string]: any}>) { - return deepmerge(...objs, { - arrayMerge: (destinationArray, sourceArray, options) => sourceArray, - }); -} diff --git a/packages/cli/src/tools/merge.ts b/packages/cli/src/tools/merge.ts new file mode 100644 index 000000000..cf4817ba2 --- /dev/null +++ b/packages/cli/src/tools/merge.ts @@ -0,0 +1,15 @@ +import deepmerge from 'deepmerge'; + +/** + * `deepmerge` concatenates arrays by default instead of overwriting them. + * We define custom merging function for arrays to change that behaviour + */ +export default function merge( + x: Array<{[key: string]: any}>, + y: Array<{[key: string]: any}>, +) { + return deepmerge(x, y, { + arrayMerge: (_destinationArray: any[], sourceArray: any[]): any[] => + sourceArray, + }); +}