[improvement] organize type definitions

This commit is contained in:
陈嘉涵
2019-05-13 19:07:04 +08:00
parent 96b1d8f81d
commit 7755b1738e
40 changed files with 111 additions and 121 deletions

View File

@@ -1,13 +1,10 @@
/* eslint-disable no-use-before-define */
import { isDef, isObj } from '.';
import { ObjectIndex } from './types';
const { hasOwnProperty } = Object.prototype;
type Object = {
[key: string]: any;
}
function assignKey(to: Object, from: Object, key: string) {
function assignKey(to: ObjectIndex, from: ObjectIndex, key: string) {
const val = from[key];
if (!isDef(val)) {
@@ -21,7 +18,7 @@ function assignKey(to: Object, from: Object, key: string) {
}
}
export function deepAssign(to: Object, from: Object) {
export function deepAssign(to: ObjectIndex, from: ObjectIndex): ObjectIndex {
Object.keys(from).forEach(key => {
assignKey(to, from, key);
});