Remove merge helper and add more type declarations. (#5649)

This commit is contained in:
Logan Smyth 2017-04-18 19:08:39 -07:00 committed by GitHub
parent 6af8e64711
commit 0eae6a432c
3 changed files with 25 additions and 22 deletions

View File

@ -7,3 +7,27 @@ declare module "micromatch" {
nocase: boolean, nocase: boolean,
}): Array<string>; }): Array<string>;
} }
declare module "resolve" {
declare export default {
sync: (string, {| basedir: string |}) => string;
};
}
declare module "json5" {
declare export default {
parse: (string) => mixed,
};
}
declare module "lodash/defaults" {
declare export default <T: Object>(T, Object) => T;
}
declare module "lodash/clone" {
declare export default <T>(obj: T) => T;
}
declare module "lodash/merge" {
declare export default <T: Object>(T, Object) => T;
}

View File

@ -1,21 +0,0 @@
// @flow
import mergeWith from "lodash/mergeWith";
export default function<T: {}>(dest?: T, src?: T) {
if (!dest || !src) return;
mergeWith(dest, src, function (a, b) {
if (b && Array.isArray(a)) {
const newArray = b.slice(0);
for (const item of a) {
if (newArray.indexOf(item) < 0) {
newArray.push(item);
}
}
return newArray;
}
});
}

View File

@ -4,7 +4,7 @@ import * as context from "../index";
import Plugin from "./plugin"; import Plugin from "./plugin";
import * as messages from "babel-messages"; import * as messages from "babel-messages";
import defaults from "lodash/defaults"; import defaults from "lodash/defaults";
import merge from "./helpers/merge"; import merge from "lodash/merge";
import removed from "./removed"; import removed from "./removed";
import buildConfigChain from "./build-config-chain"; import buildConfigChain from "./build-config-chain";
import path from "path"; import path from "path";